TreeviewCopyright © aleen42 all right reserved, powered by aleen42

1518. 换酒问题

https://leetcode-cn.com/problems/water-bottles/

Java

/*
 * @Author: Goog Tech
 * @Date: 2020-09-02 21:55:37
 * @LastEditTime: 2020-09-02 21:55:43
 * @Description: https://leetcode-cn.com/problems/water-bottles/
 * @FilePath: \leetcode-googtech\#1518. Water Bottles\Solution.java
 * @WebSite: https://algorithm.show/
 */

class Solution {
    public int numWaterBottles(int numBottles, int numExchange) {
        int emptyBottles = numBottles;
        while(emptyBottles >= numExchange) {
            numBottles = numBottles + emptyBottles / numExchange;
            emptyBottles = emptyBottles / numExchange + emptyBottles % numExchange;
        }
        return numBottles;
    }
}

Python

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

        ''' 待解. . . '''
Copyright © GoogTech 2021 all right reserved,powered by GitbookLast update time : 2021-09-15 01:55:05

results matching ""

    No results matching ""