原文地址: https://www.douban.com/note/690615996/
kris 2018-09-19 19:03:54
不存在借瓶或者盖子哈!纯数学算,python代码如下:
money = 100
bottals = money/2
drink_bottal = bottals
tops = bottals
def recur(drink_bottal, tops, bottals):
conti = False
if tops >= 4:
drink_bottal+=1
bottals +=1
tops-=3
conti = True
if bottals>=2:
drink_bottal+=1
tops+=1
bottals -=1
conti = True
if conti:
recur(drink_bottal, tops, bottals)
else:
print("drink:%d,left tops:%d,left bottals:%d" % (drink_bottal, tops, bottals))
recur(drink_bottal, tops, bottals)