yubin_repository/Greedy Algorithm

16 lines
177 B
Plaintext
Raw Permalink Normal View History

2018-10-26 10:04:21 +00:00
a=[50, 5, 2]
an=56
bn=54
t=0
ans=[]
while 1:
if an < a[t]:
break
while an>a[t]:
ans.append(a[t])
an = an - a[t]
t += 1
print(an)
print(ans)