1 条题解

  • 1
    @ 2022-11-5 11:20:30
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
        cin>>n;
        while(n!=1)
        {
            if(n% 2==1)
            {
                cout<<n<<"*3+1="<<n*3+1<<"\n";
                n = n*3 +1;
            }
            if(n %2==0)
            {
                cout<<n<<"/2="<<n/2<<"\n";
                n = n/ 2;
            }
        }
        cout<<"End\n";
        return 0;
    }
    
    • 1

    信息

    ID
    306
    时间
    1000ms
    内存
    128MiB
    难度
    4
    标签
    (无)
    递交数
    238
    已通过
    108
    上传者