3 solutions

  • 0
    @ 2023-10-27 22:50:27
    #include<iostream>
    using namespace std;
    void Jcgu(int x){
      if(x==1)cout<<"End";
      else if(x%2==0){
        printf("%d/2=%d\n",x,x/2);
        Jcgu(x/2);
      }
      else{
        printf("%d*3+1=%d\n",x,x*3+1);
        Jcgu(x*3+1);
      }
    }
    int main(){
      int n;
      cin>>n;
      Jcgu(n);
      return 0;
    }
    

    Information

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