空酒瓶问题:
小区便利店正在促销,用 numExchange 个空酒瓶可以兑换一瓶新酒。你购入了 numBottles 瓶酒。
如果喝掉了酒瓶中的酒,那么酒瓶就会变成空的。
请你计算 最多 能喝到多少瓶酒。
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/water-bottles
count=0
def numWater(numBottles, numExchange):
if numBottles>=numExchange:
a = numBottles//numExchange
b = numBottles%numExchange
numBottles=a+b#剩余的空酒瓶数
global count
count+=a
numWater(numBottles,numExchange)
else:
return
numBottles = int(input("初始酒瓶数:"))
c = numBottles
numExchange = int(input("空酒瓶交换数:"))
numWater(numBottles, numExchange)
print(count+c)