7 solutions

  • 11
    @ 2024-10-13 9:24:16
    #include<bits/stdc++.h>
    using namespace std;
    int main ()
    {
    	int n;
    	cin>>n;
    	while(n!=1)
    	{
    		if (n%2==0)
    		{
    			n=n/2;
    			cout<<n*2<<"/2="<<n<<endl;
    		}
    		else
    		{
    			n=n*3+1;
    			cout<<(n-1)/3<<"*3+1="<<n<<endl;
    		}
    	}
    	cout<<"End";
        return 0;
    }
    
    • 5
      @ 2025-5-28 20:02:28
      ```cpp
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      	int n;
      	cin>>n;
      	while(n!=1)
      	{
      		if(n%2==0)
      		{
      			cout<<n<<"/2="<<n/2<<endl;
      			n=n/2;
      		}
      		else
      		{
      			cout<<n<<"*3+1="<<n*3+1<<endl;
      			n=n*3+1;
      		}
      	}
      	cout<<"End";
      	return 0;
      }
      
      
      • 1
        @ 2026-8-7 14:46:38
        #include<bits/stdc++.h>
        using namespace std;
        int main()
        {
            int n;
        	cin>>n;
            while(n!=1)
        	{
        		if(n%2==0)
        		{
        			int a=n/2;
        			cout<<n<<"/2="<<a<<endl;
                    n=a;
        		}
        		else
        		{
        			int b=n*3+1;
        			cout<<n<<"*3+1="<<b<<endl;
                    n=b;
        		}
        	}
        	cout<<"End";
        	return 0;
        }
        
        • -1
          @ 2026-1-10 10:34:53
          • [ ] `
          )
          1. - > # **<u>*~~~~*</u>**
          

          `

          • -3
            @ 2024-10-13 9:24:48
            #include<bits/stdc++.h>
            using namespace std;
            int main()
            {
            	int n;
            	cin>>n;
            	while(n!=1)
            	{
            		if(n%2==0)
            		{
            			n=n/2;
            			cout<<n*2<<"/2="<<n<<endl;
            		}
            		else
            		{
            		n=n*3+1;
            		cout<<(n-1)/3<<"*3+1="<<n<<endl;
               		}
            	}
            	cout<<"End";
            	return 0;
            }
            
            • -11
              @ 2024-10-13 9:24:59

              1+1=0

              • -11
                @ 2024-10-13 9:24:49

                1+1=0

                • 1

                Information

                ID
                866
                Time
                1000ms
                Memory
                256MiB
                Difficulty
                1
                Tags
                (None)
                # Submissions
                495
                Accepted
                117
                Uploaded By