fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int t;
  7. cin>>t;
  8. while(t--)
  9. {
  10. int A,B;
  11. int count=0;
  12. cin>>A>>B;
  13. int n=A^B;
  14. while(n)
  15. {
  16. n=n&(n-1);
  17. count++;
  18. }
  19. cout<<count<<endl;
  20. }
  21. }
Success #stdin #stdout 0.01s 5436KB
stdin
4
20 10
16 8
1 153
549 24
stdout
4
2
3
6