题解 | #位操作练习#
位操作练习
https://www.nowcoder.com/practice/7bdc346ca39841f6a05f73d98477621d
#include<iostream> #include<cmath> using namespace std; int main(){ unsigned short a; unsigned short b; while(cin>>a>>b){ for(int i=0;i<16;i++){ if(a==b){ cout<<"YES"<<endl; break; } if(a&1<<15){ a=a-pow(2,15); a=a*2+1; }else{ a=a*2; } if(i==15) cout<<"NO"<<endl; } } }