B1001

#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;

int main()
{
    int n,k=0;
    scanf("%d",&n);
    while(n!=1){
        if(n%2==0)
            n/=2;
        else
            n=(3*n+1)/2;
        k++;
    }
    printf("%d\n",k);
    return 0;
}
 

按照题目顺着写就行

猜你喜欢

转载自blog.csdn.net/fengwuyaQAQ/article/details/85608705