计算m和n二进制表示上的不同位数,等价于计算m异或n的值中二进制'1'的个数

C++版本

#include <iostream>

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);

  int m,n;
  std::cin >> m >> n;

  std::cout << __builtin_popcount(m ^ n) << "\n";
}

Python版本

import sys

input = lambda : sys.stdin.readline().strip()

m,n = map(int,input().split())

print(bin(m ^ n).count('1'))