题解 | #位操作练习#

位操作练习

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");
    }
}

全部评论

相关推荐

我:“加班需要有加班工资。”&nbsp;hr:“为什么?”&nbsp;哈哈哈哈哈哈哈离大谱
juntenor:你确实太理想化了,对社会不了解呀。这个和HR没有关系,这是国内特色,不然怎么还会有外包就这种逆天的存在呢。
点赞 评论 收藏
分享
06-19 19:06
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务