3 solutions

  • 1
    @ 2023-10-2 16:39:50
    #include<bits/stdc++.h>
    using namespace std;
    int ans;
    void judge(int k)
    {
    
    	if(k==1)
    		cout<<"End";
    	else
    	{
    		if(k%2==0)
    		{
    			ans=k/2;
    			cout<<k<<"/2="<<ans<<endl;
    		}
    		else
    		{
    			ans=k*3+1;
    			cout<<k<<"*3+1="<<ans<<endl;
    		}
    	}
    }
    
    int main()
    {
    	int n;
    	cin>>n;
    	judge(n);
    	while(ans!=1)
    		judge(ans);
    	if(n!=1)
    		cout<<"End";
    	return 0;
    }
    

    Information

    ID
    6752
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    8
    Tags
    (None)
    # Submissions
    332
    Accepted
    60
    Uploaded By