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; }
By signing up a 津桥OJ universal account, you can submit code and join discussions in all online judging services provided by us.
Using your 津桥OJ universal account