1 solutions

  • 0
    @ 2025-3-3 16:24:10

    C++ :

    #include<cstdio>
    #define LL long long
    //函数功能:求出整数n二进制表示中1的个数
    LL getOneNumber(LL n)
    {
        LL cnt=0;
        while(n)
            n&=n-1,cnt++;
        return cnt;
    }
    int main()
    {
        LL a,b;
        while(~scanf("%lld%lld",&a,&b))
            printf("%lld\n",getOneNumber(a^b));
        return 0;
    }
    
    
    • 1

    Information

    ID
    10041
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By