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