提交时间:2020-08-17 13:36:53
运行 ID: 5933
#include<iostream> using namespace std; int main() { int n; while(cin>>n) { if(n==0) return 0; int ans=0; ans+=n/3; n=n%3; n+=ans; while(n>=3) { int s=n/3; ans+=s; n=n%3; n+=s; } if(n==2)ans++; cout<<ans<<endl; } return 0; } //3 1 3 //4 3 //1 1 4