题解 | 二进制不同位数

二进制不同位数

https://www.nowcoder.com/practice/daf9032926614dab91ca624a7759a868

#include <iostream>
using namespace std;
#define int long long

signed main() {
    int m,n;cin>>m>>n;
    int x=m^n;
    int num=0,i=0;
    while(i<64){
        if((x>>i)&1) num++;
        i++;
    }
    cout<<num;
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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