Appearance
题目
分析
酒 -> 空瓶 -> 酒 -> 空瓶 这太递归了。
代码
python
class Solution(object):
def numWaterBottles(self, numBottles, numExchange):
"""
:type numBottles: int
:type numExchange: int
:rtype: int
"""
exchange = numBottles//numExchange
if exchange==0:
return numBottles
else:
left = numBottles%numExchange
return numBottles + self.numWaterBottles(left+exchange, numExchange) - left