//傻瓜做法 #include<iostream> #include<string> #include<algorithm> using namespace std; void isok(string s, string t) { string rem = s + s; if (rem.find(t) != string::npos) { cout << "YES" << endl; } else { cout << "NO" << endl; } } int main() { int a, b; while (cin >> a >> b) { string sa, sb; while (a > 0) { sa += a % 2 + '0'; a /= 2; } while (b > 0) { sb += b % 2 + '0'; b /= 2; } int la = sa.size(), lb = sb.size(); for (int i = 0; i < 16 - la; i++) { sa += '0'; } for (int i = 0; i < 16 - lb; i++) { sb += '0'; } reverse(sa.begin(), sa.end()); reverse(sb.begin(), sb.end()); isok(sa, sb); } return 0; }