举杯消愁愁更愁,月底账单入水流 • 6个月前
#include<bits/stdc++.h>
using namespace std;
int n,cnt;
void b(int n){
if(n==1) return ;
if(n%2==0){
cnt++;
b(n/2);
}else{
cnt++;
b(n*3+1);
}
}
int main(){
scanf("%d",&n);
b(n);
printf("%d",cnt);
return 0;
}
评论:
请先登录,才能进行评论