题解 | #位操作练习#
位操作练习
https://www.nowcoder.com/practice/7bdc346ca39841f6a05f73d98477621d
#include<iostream> #include<bitset> using namespace std; int main(void) { int a,b; while(cin >> a >> b) { bitset<16>b1(a); bitset<16>b2(b); bool f = true; for(int i = 0; i < 16;i++) { f = true; for(int j = 0;j < 16;j++) { int new_index = (j + i) % 16; if(b1[new_index] != b2[j]){ f = false; break; } } if(f) break; } if(f) cout << "YES\n"; else cout << "NO\n"; } return 0; }