1 条题解

  • 0
    @ 2023-8-30 21:01:23
    #include<bits/stdc++.h>
    using namespace std;
    int a[11111111];
    int gao(long long x)
    {
        if(x==1) return 1;
        if(x<10000000&&a[x]) return a[x];
        int tmp;
        if(x%2==0)
            tmp=gao(x/2)+1;
        else
            tmp=gao(x*3+1)+1;
        if(x<10000000) a[x]=tmp;
        return tmp;
    }
    int main()
    {
        int n;
        cin>>n;
        cout<<gao(n)-1<<endl;
        return 0;
    }
    
    • 1

    [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏

    信息

    ID
    1666
    时间
    1000ms
    内存
    256MiB
    难度
    10
    标签
    (无)
    递交数
    3
    已通过
    3
    上传者