#include <stdio.h> int main() { int a, b; int count=0; while (scanf("%d %d", &a, &b) != EOF) { // 注意 while 处理多个 case // 64 位输出请用 printf("%lld") to int tmp=a^b; while(tmp) { tmp=tmp&(tmp-1); count++; } printf("%d\n", count); } return 0; }
#include <stdio.h> int main() { int a, b; int count=0; while (scanf("%d %d", &a, &b) != EOF) { // 注意 while 处理多个 case // 64 位输出请用 printf("%lld") to int tmp=a^b; while(tmp) { tmp=tmp&(tmp-1); count++; } printf("%d\n", count); } return 0; }