5 solutions

  • 0
    @ 2026-8-25 20:15:52
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
    	while(cin>>n,n)
    	{
    		int s=0;
    		while(n>=3)
    		{
    			s+=n/3;
    			n=n/3+n%3;
    		}
    		if(n==2)
    		{
                s++;
    		}
    		cout<<s<<endl;
    	}
    	return 0; 
    }

    Information

    ID
    2879
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    1
    Tags
    # Submissions
    98
    Accepted
    49
    Uploaded By