7-10 sdut-汉明距离

知识点:

转化为指定长度的二进制

代码:

import string


a,b=map(int,input().split())
maxn=max(a,b)

cnt1=list(format(a,"031b"))
cnt2=list(format(b,"031b"))

ans=0

for i in range(31):
    if cnt1[i]!=cnt2[i]:
        ans+=1
print(ans)
posted @ 2022-05-27 17:35  kingwzun  阅读(32)  评论(0编辑  收藏  举报