思路:模拟。根据题意,把m和n异或起来,然后统计异或结果中二进制的1数目即可
注意:本题采用的是字符串处理,用python3会比pypy3快
代码:
import sys
input = lambda: sys.stdin.readline().strip()
import math
inf = 10 ** 18
def I():
return input()
def II():
return int(input())
def MII():
return map(int, input().split())
def GMI():
return map(lambda x: int(x) - 1, input().split())
def LI():
return input().split()
def LII():
return list(map(int, input().split()))
def LFI():
return list(map(float, input().split()))
fmax = lambda x, y: x if x > y else y
fmin = lambda x, y: x if x < y else y
isqrt = lambda x: int(math.sqrt(x))
'''
如果平台的python版本高点,可以写以下代码:
print((m ^ n).bit_count())
'''
def solve():
m, n = MII()
print(bin(m ^ n)[2:].count('1'))
t = 1
# t = II()
for _ in range(t):
solve()

京公网安备 11010502036488号