题解 | #位操作练习#
位操作练习
https://www.nowcoder.com/practice/7bdc346ca39841f6a05f73d98477621d
#include <stdio.h> int main(){ unsigned short int a,b; int len = sizeof(unsigned short int)*8; unsigned short int shifted=0; while (scanf("%hu %hu",&a,&b)==2){ bool success=false; for(int i=0;i<len;i++){ shifted = (a<<i)|(a>>len-i); if(shifted==b){ success=true; break; } } if(success) printf("YES\n"); else printf("NO\n"); } }