5 solutions

  • 1
    @ 2026-8-11 14:50:39
    #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; 
    }
    
    • 1
      @ 2025-9-7 11:43:58
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      	int n;
      	while(cin>>n,n)
      	{
      		int ans=0;
      		while(n>=3)
      		{
      			ans+=n/3;
      			n=n/3+n%3;
      		}
      		if(n==2) ans++;
      		cout<<ans<<endl;
      	}
      	return 0;
      }
      
      
      • 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; 
        }
        • -1
          @ 2026-7-17 9:25:48
          ##### #### ### ##
          • -1
            @ 2025-11-27 21:31:14

            #include<bits/stdc++.h> using namespace std; int main() { int n; while(cin>>n,n) { int ans=0; while(n>=3) { ans+=n/3; n=n/3+n%3; } if(n==2) ans++; cout<<ans<<endl; } return 0; }

            • 1

            Information

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