震撼首发
2026-03-04 19:58:46
发布于:江苏
1阅读
0回复
0点赞
考点为模拟
#include<bits/stdc++.h>
using namespace std;
int n,maxx;
int main(){
cin>>n;
if(n==1){
cout<<4;
return 0;
}//n=1时特判更简单
while(n!=1){//n=1时循环结束
if(n%2)n=n*3+1;//n为奇数
else n/=2;//n为偶数
maxx=max(maxx,n);//确定最大值
}
cout<<maxx<<"\n";
return 0;
}
这里空空如也



有帮助,赞一个