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