#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int n,cnt=0;
cin>>n;
while(n!=1)
{
if(n%2==0) n=n/2;
else n=(3*n+1)/2;
cnt++;
}
cout<< cnt;
return 0;
}
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int n,cnt=0;
cin>>n;
while(n!=1)
{
if(n%2==0) n=n/2;
else n=(3*n+1)/2;
cnt++;
}
cout<< cnt;
return 0;
}
本文标题:PAT 1001 害死人不偿命的(3n+1)猜想 (15 分)
本文链接:https://www.haomeiwen.com/subject/igashqtx.html
网友评论