class Solution {
public:
int numWaterBottles(int numBottles, int numExchange) {
int drink_num = numBottles;
while(numBottles >= numExchange) {
drink_num = drink_num + numBottles/numExchange;
numBottles = numBottles/numExchange + numBottles%numExchange;
}
return drink_num;
}
};
1518. Water Bottles
最新推荐文章于 2024-08-20 10:48:49 发布