思路
模拟案例:
饮料数:100 0 33 0 11 0 4 0 1 0 0
瓶盖数:0 100 1 34 1 12 0 4 1 1 1
喝过数:0 100 100 133 133 144 144 148 148 149 149
性质:
1.当瓶盖数不小于3时可以一直换
2.每次白嫖n / 3瓶
3.每次换完得到n / 3 + n % 3个盖
c++代码
#include <bits/stdc++.h>
using namespace std;
int n;
int res;
int main()
{
cin >> n;
res = n;
while(n >= 3)
{
res += n / 3;
n = n / 3 + n % 3;
}
cout << res << endl;
return 0;
}