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