5 solutions

  • 6
    @ 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;
    }
    
    • 1
      @ 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
        @ 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;
        }
        
        • -7
          @ 2024-10-13 9:24:59

          1+1=0

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

            1+1=0

            • 1

            Information

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