题目1151:位操作练习

来源:互联网 发布:sql注入测试网站 编辑:程序博客网 时间:2024/05/14 17:56
#include <cstdio>#include <iostream>#include <fstream>using namespace std;int main(){    unsigned short a, b;    int t;#ifndef ONLINE_JUDGE    freopen("d:\\OJ\\uva_in.txt", "r", stdin);#endif    scanf("%d", &t);    while (t-- > 0) {        scanf("%hu%hu", &a, &b);        int i;        for (i = 0; i < 16; i++) {            unsigned short tmp = (a << i) | (a >> (16 - i));            if (tmp == b) {                printf("YES\n");                break;            }        }        if (i >= 16) {            printf("NO\n");        }    }    return 0;}

0 0
原创粉丝点击