题解 | #xxx定律#
xxx定律
https://www.nowcoder.com/practice/75c189249d6145cfa33cd53edae6afc8
#include <stdio.h> #include <string.h> int func(int n,int count) { if(n==1) return count; else if(n%2==0) { return func(n/2,count+1); } else { return func((3*n+1)/2,count+1); } } int main() { int n; while(scanf("%d",&n)!=EOF) { printf("%d\n",func(n,0)); } return 0; }