2 条题解

  • 3
    @ 2025-12-2 19:22:02
    #include<bits/stdc++.h>
    using namespace std;
    void f(long long n){
        if(n==1)
    	{
            cout<<"End";
            return;
        }
        else if(n%2==0)
    		{
            	cout<<n<<"/2="<<n/2<<endl;
            	f(n/2);
        	}
            else
    			{
                	cout<<n<<"*3+1="<<n*3+1<<endl;
                	f(n*3+1);
            	}
    }
    int main(){
        long long n;
        cin>>n;
        f(n);
        return 0;
    }
    
    • -1
      @ 2025-12-4 20:25:34

      #include<bits/stdc++.h> using namespace std; void f(long long n){ if(n1) { cout<<"End"; return; } else if(n%20) { cout<<n<<"/2="<<n/2<<endl; f(n/2); } else { cout<<n<<"3+1="<<n3+1<<endl; f(n*3+1); } } int main(){ long long n; cin>>n; f(n); return 0; }

      • 1

      信息

      ID
      6934
      时间
      1000ms
      内存
      128MiB
      难度
      1
      标签
      递交数
      9
      已通过
      7
      上传者