#include <iostream>
#include <vector>
#include <algorithm>
#include<string>
using namespace std;
int main() {
int a, b;
while (cin >> a >> b) {
//还有一种更简单的方法
//注意题目已经说了长度为16位
string x,y;
for(int i=15;i>=0;i--){
x+=to_string(a>>i&1);//先取出最高位
y+=to_string(b>>i&1);
}
//将其中一个扩大一倍
y+=y;
if(y.find(x)!=string::npos){
cout<<"YES"<<endl;
}
else
cout<<"NO"<<endl;
}
}



京公网安备 11010502036488号