4 solutions

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

        1+1=0

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

          1+1=0

          • 1

          Information

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