// 浙大09机试
// 3n+1
//
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
int n;
while(scanf("%d", &n) && n)
{
int ans=0;
while(n != 1)
{
ans++;
if(n%2 == 0)
{
n /= 2;
}
else
{
n = (3*n + 1) / 2;
}
}
printf("%d\n", ans);
}
return 0;
}
九度:1031<3n+1>
最新推荐文章于 2014-03-10 14:21:38 发布