思路:模拟题。每次&运算取最后一位加到答案中,然后不断右移即可
代码:
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 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))
'''
'''
def solve():
x = II()
cnt = 0
while x:
cnt += x & 1
x >>= 1
print(cnt)
t = 1
# t = II()
for _ in range(t):
solve()

京公网安备 11010502036488号