#include<stdio.h> int main() { int n,cnt=0; scanf("%d",&n); while(n!=1) { if(n%2==0) n/=2; else n=(3*n+1)/2; ++cnt; } printf("%d\n",cnt); return 0; }
时间: 2024-11-06 14:56:43
#include<stdio.h> int main() { int n,cnt=0; scanf("%d",&n); while(n!=1) { if(n%2==0) n/=2; else n=(3*n+1)/2; ++cnt; } printf("%d\n",cnt); return 0; }