题解 | xxx定律
#include<stdio.h>
//对于一个数n,如果是偶数,就把n砍掉一半;
// 如果是奇数,把n变成 3*n+ 1后砍掉一半,直到该数变为1为止。
// 请计算需要经过几步才能将n变到1,具体可见样例。
int main() {
int n;
int count = 0;
scanf("%d", &n);
while(n!=1){
if (n % 2 == 0) {
n = n / 2;
}
else {
n = (3 * n + 1)/2;
}
count++;
}
printf("%d\n", count);
return 0;
}