Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- bool check (int a, int b){
- while(a<b){
- a = a*2+1;
- }
- if (a==b) return 1;
- else return 0;
- }
- int main(){
- ios::sync_with_stdio(0);
- cin.tie(0);
- int a, b;
- cin >> a >> b;
- int x = a;
- int index = 0;
- while (x<b){
- x = x*3;
- index++;
- }
- if (a*index*3==b) cout << "YES" << endl;
- else{
- int arr[b];
- int res = 0;
- for (int i=1;i<=b;i++){
- arr[i-1] = 2*i*3;
- }
- for (int i=0;i<b;i++){
- if (check(arr[i],b)) res++;
- }
- if (res>0) cout << "YES" << endl;
- else cout << "NO";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement