题解 | #xxx定律#
xxx定律
https://www.nowcoder.com/practice/75c189249d6145cfa33cd53edae6afc8
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n;
int count=0;
// cin>>n;
int t=n;
while(cin>>n){
while(n!=1){
if(n%2==0)
{
n=n/2;
}
else
n=(3*n+1)/2;
count++;
}
cout<<count<<endl;
}
// if(n%2!=0)
// {
// while(true){
// if(t==1)
// {
// cout<<count<<endl;
// break;
// }
// t=t+t+t+1;
// t=t/2;
// count++;
//
// }
// }
// else{
// while(true){
// if(t==1)
// {
// cout<<count<<endl;
// break;
// }
// t=t/2;
// count++;
// }
// }
//
//
//
//
}
注解的代码会超时,不懂为什么?
