题解 | #xxx定律#
xxx定律
https://www.nowcoder.com/practice/75c189249d6145cfa33cd53edae6afc8
//XXX定律 浙大 2024/1/4
//http://t.cn/E937wDs
#include <iostream>
using namespace std;
int call;//全局变量记录处理函数调用次数,即所求步数
int delNum(int n){
call++;
if(n%2==0) return n/2;
else return (3*n+1)/2;
}
int main() {
int n;
while (cin >> n) {
call=0;
while(n!=1) n=delNum(n);//反复调用,直至满足要求
cout<<call<<endl;;
}
return 0;
}

