直接去模拟过程就行了
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<math.h>
#include<set>
#include<string>
#include<stack>
using namespace std;
#include<queue>
int main()
{
int n = 0;
cin >> n;
int ans = n;//ans保存共喝到的饮料
while (n >= 3)
{
int tmp = n / 3;//tmp表示喝完上一波能换的饮料数目
n %= 3;//换完还剩的s上一波饮料数目
n += tmp;//上一波还剩的+这一波换的
ans += tmp;
}
cout << ans;
return 0;
}