#include <bits/stdc++.h>
typedef long long LL;
using namespace std;
int main()
{
int n,res=0;
cin>>n;
res=n;
while(n>=3)
{
res+=(n/3);
n=n/3+(n%3);
}
cout<<res<<endl;
return 0;
}
1 回复
0 转发
0 喜欢
23 阅读
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;
int main()
{
int n,res=0;
cin>>n;
res=n;
while(n>=3)
{
res+=(n/3);
n=n/3+(n%3);
}
cout<<res<<endl;
return 0;
}n/3 + n%3 的处理很细致,把每次剩下的空瓶都考虑进去了。