题解 | 求int型正整数在内存中存储时1的个数
n = int(input())
a = bin(n).replace('0b', '')
b = a.replace('0', '')
c = []
for i in b:
c.append(i)
print(len(c))
n = int(input())
a = bin(n).replace('0b', '')
b = a.replace('0', '')
c = []
for i in b:
c.append(i)
print(len(c))
相关推荐
查看21道真题和解析