aboutsummaryrefslogtreecommitdiff
path: root/water_bottles2.py
blob: 19af620a608abd2a2f885bc94972eca1302bb2b8 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 3100. Water Bottles II

"""
you are given two integers 'numBottles' and 'numExchange'. 'numBottles'
represents the number of full water bottoles that you are initially given. in
one operation, you can perform one of the following operations: drink any
number of full bottles, turning them into empty bottles, or exchange
'numExchange' empty bottles with one full water bottle, then increase
'numExchange' by 1. return the maximum number of water bottles you can drink
"""


class Solution(object):
    def maxBottlesDrunk(self, numBottles, numExchange):
        """
        :type numBottles: int
        :type numExchange: int
        :rtype: int
        """


class Solution(object):
    def maxBottlesDrunk(self, numBottles, numExchange):
        """
        :type numBottles: int
        :type numExchange: int
        :rtype: int
        """
        ans = numBottles
        while numBottles >= numExchange:
            numBottles -= numExchange - 1
            numExchange += 1
            ans += 1
        return ans


if __name__ == "__main__":
    ans = numBottles
    while numBottles >= numExchange:
        numBottles -= numExchange - 1
        numExchange += 1
        ans += 1
    return ans


if __name__ == "__main__":
    obj = Solution()
    print(obj.maxBottlesDrunk(13, 6))
    print(obj.maxBottlesDrunk(10, 3))