You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
527 B

#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;
}