Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. bool check (int a, int b){
  4. while(a<b){
  5. a = a*2+1;
  6. }
  7. if (a==b) return 1;
  8. else return 0;
  9. }
  10. int main(){
  11. ios::sync_with_stdio(0);
  12. cin.tie(0);
  13.  
  14. int a, b;
  15. cin >> a >> b;
  16. int x = a;
  17. int index = 0;
  18.  
  19. while (x<b){
  20. x = x*3;
  21. index++;
  22. }
  23. if (a*index*3==b) cout << "YES" << endl;
  24. else{
  25. int arr[b];
  26. int res = 0;
  27. for (int i=1;i<=b;i++){
  28. arr[i-1] = 2*i*3;
  29. }
  30. for (int i=0;i<b;i++){
  31. if (check(arr[i],b)) res++;
  32. }
  33. if (res>0) cout << "YES" << endl;
  34. else cout << "NO";
  35. }
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement