Files
python/TangDou/KaoShi/空瓶换饮料.cpp

23 lines
527 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <iostream>
using namespace std;
int n; // 换回来的饮料数量
int sum; // 喝到总数
int t; // 空瓶数量
int main() {
cin >> n;
while (n) {
//① 统计上轮结果
sum += n; // 上轮换回来的可以喝到
t += n; // 当前手中酒瓶 = 原空瓶数量+上轮换回
//② 本轮换取开始
n = t / 3; // 换回来的饮料数量
t %= 3; // 剩余空瓶
}
//输出
printf("%d", sum);
return 0;
}