bzoj 1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏【模拟】

模拟

#include<iostream>
#include<cstdio>
using namespace std;
int n,ans;
int main()
{
    scanf("%d",&n);
    for(;n>1;ans++)
    {
        if(n&1)
            n=n*3+1;
        else
            n>>=1;
    }
    printf("%d\n",ans);
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/lokiii/p/8961528.html