1518. 换酒问题
class Solution {
public:
int numWaterBottles(int numBottles, int numExchange) {
int res=numBottles;
while(numBottles>=numExchange){
res+=numBottles/numExchange;
numBottles=numBottles/numExchange+numBottles%numExchange;
}
return res;
}
};
网友评论