Skip to content

Latest commit

 

History

History
13 lines (12 loc) · 343 Bytes

1518. 换酒问题.md

File metadata and controls

13 lines (12 loc) · 343 Bytes
class Solution {
    public int numWaterBottles(int numBottles, int numExchange) {
        int bottles = numBottles;
        while (numBottles >= numExchange) {
            bottles += numBottles / numExchange;
            numBottles = numBottles / numExchange + numBottles % numExchange;
        }
        return bottles;
    }
}