一共有1,2,5,10元的货币,要组合成x元
from copy import copy
f = open('台阶.txt', 'w', encoding='utf-8')
def func(num=0, ls=[]):
ls.append(num)
if sum(ls) > 20:
return
if sum(ls) == 20:
print(ls[1:], file=f)
return
for i in [1, 2, 5, 10]:
func(i, copy(ls))
func()
网友评论