PAT乙级1001

https://pintia.cn/problem-sets/994805260223102976/problems/994805325918486528

#include<bits/stdc++.h>
using namespace std;
int n,sum;
int main()
{
    cin>>n;
    while(n!=1)
    {
        if(n&1)
            n=(3*n+1)/2;
        else
            n/=2;
        sum++;
    }
    cout<<sum;
    return 0;
}

 

posted @ 2019-03-25 14:40  zuiaimiusi  阅读(103)  评论(0编辑  收藏  举报