题解 | 求int型正整数在内存中存储时1的个数
求int型正整数在内存中存储时1的个数
https://www.nowcoder.com/practice/440f16e490a0404786865e99c6ad91c9
n = int(input())
red = []
while(n > 1):
red.append(n % 2)
n = int(n / 2)
if n == 1:
red.append(1)
elif n == 0:
red.append(0)
print(red.count(1))
智元机器人成长空间 351人发布
查看16道真题和解析
