blob: 0ada9f7eccc6e9652a4d33341e8e743fce184ac0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# 1518. Water Bottles
"""
there are 'numBottles' water bottles that are initially full of water. you
can exchange 'numExchange' empty water botls from the market with one full
water bottle. the operation of drinking a full water bottle turns into an
empty bottle. given the two integers 'numBottles' and 'numExchange', return
the maximum number of water bottles you can drink
"""
class Solution(object):
def numWaterBottles(self, numBottles, numExchange):
"""
:type numBottles: int
:type numExchange: int
:rtype: int
"""
return (numBottles * numExchange - 1) // (numExchange - 1)
if __name__ == "__main__":
obj = Solution()
print(obj.numWaterBottles(9, 3))
print(obj.numWaterBottles(15, 4))
|