题解 | #xxx定律#
xxx定律
https://www.nowcoder.com/practice/75c189249d6145cfa33cd53edae6afc8
#include <cstdio>
#include <iostream>
using namespace std;
int XXXRegular(int n);
int main() {
int a;
while (cin >> a ) { // 注意 while 处理多个 case
XXXRegular(a);
}
}
int XXXRegular(int n) {
int total = 0;
while (n != 1) {
if (n % 2 == 0) {
n = n / 2;
} else {
n = (3 * n + 1) / 2;
}
total++;
}
cout << total << endl;
return 0;
}
// 64 位输出请用 printf("%lld")
