时间轴

2025-10-01

init


题目:

简单的数学模拟题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
class Solution {
public:
int numWaterBottles(int numBottles, int numExchange) {
// 每numExchange个bottles喝完可以换一瓶bottle
int exchange_bootles = -1;
int total_water = 0;
do {
exchange_bootles = numBottles / numExchange;
numBottles = numBottles % numExchange;
numBottles += exchange_bootles;
total_water += exchange_bootles * numExchange;

} while (numBottles >= numExchange);
total_water += numBottles;
return total_water;
}
};