题解 | 查找输入整数二进制中1的个数
查找输入整数二进制中1的个数
https://www.nowcoder.com/practice/1b46eb4cf3fa49b9965ac3c2c1caf5ad
import sys a = int(input()) b= int(input()) ab= bin(a)[2:] bb = bin(b)[2:] for i in [ab,bb]: count = 0 for _ in i: if _ == '1': count +=1 print(count)
python 直接bin 然后转字符串哈希