C++

#include<string>
#include<algorithm>
using namespace std;
#define MAX 100
string trans(int a) {
	string s = "";
	while (a != 0) {
		s += (char)((a % 2) + '0');
		a /= 2;
	}
	reverse(s.begin(), s.end());
	return s;
}
//循环左移
string shiftleft(string s) {
	if (s[0] == '0') {
		s.erase(0, 1);
		s += "0";
	}
	else {
		s.erase(0, 1);
		s += "1";
	}
	return s;
}
//循环左移能得到的话就返回true,否则false
bool f(int a, int b) {
	if (a == b)return true;
	string s1 = trans(a);
	string s2 = trans(b);

	while (s1.size() != 16) {
		s1.insert(0, "0");
	}
	while (s2.size() != 16) {
		s2.insert(0, "0");
	}
	string temp = s1;
	for (int i = 1; i < s1.size(); i++) {
		temp = shiftleft(temp);
		if (temp == s2)return true;
	}
	return false;
}
int main() {
	int a, b;
	while (cin >> a >> b) {
		if (f(a, b)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}

	return 0;
}