class Solution:
def numberOfSteps(self, num: int) -> int:
ans = 0
while num != 0:
if num % 2 == 0:
num //= 2
else:
num -= 1
ans += 1
return ans
总结:
大过年的,快乐模拟