题解 | #xxx定律#
xxx定律
http://www.nowcoder.com/practice/75c189249d6145cfa33cd53edae6afc8
#include #include
using namespace std;
int main() { int n; while (scanf("%d", &n) != EOF) { int k = 0; while (n != 1) { if (n % 2 == 1) { n = (3 * n + 1) / 2; k++; } else { n = n / 2; k++; } } printf("%d\n", k); } return 0; }