chengjf
3/8/2016 - 11:49 AM

10块钱喝啤酒

10块钱喝啤酒

total = 10
bottle_money = 2
bottle_gaizi = 4
bottle_kong = 2

bottle = total/bottle_money
gaizi = bottle
kong = bottle


while kong/bottle_kong>=1 or gaizi /bottle_gaizi>=1:

    k = kong/bottle_kong
    bottle += k
    kong = kong%bottle_kong+k
    gaizi += k
    
    g = gaizi/bottle_gaizi
    bottle += g
    gaizi = gaizi%bottle_gaizi + g
    kong += g
    
    print k+g,kong,gaizi
print bottle, kong, gaizi