时间轴
时间轴
2025-10-01
init
数学,模拟
题目:
简单的数学模拟题
12345678910111213141516171819 | 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; }}; |
