标签:== money font end for i+1 bre def text
def dollar(n):
global story_money
money = []
for i in range(10):
if 2**(i+1) > story_money-sum(money):
money.append(story_money-2**i+1)
break
money.append(2 ** i)
# print(money)
answer = []
if n >= money[-1]:
answer.append(10)
n -= money[-1]
n = list(bin(n))[2:]
n.reverse()
rank = 1
for i in n:
if i == ‘1‘:
answer.append(rank)
rank += 1
print(answer)
story_money = 1000
dollar(500)
2020-05-29
标签:== money font end for i+1 bre def text
原文地址:https://www.cnblogs.com/hany-postq473111315/p/12989353.html