- 龙凤苑中学B班5.30
冰雹猜想(我做的怎么样?是不是很有水平?)
- @ 2024-5-30 12:35:31
#include<bits/stdc++.h>
using namespace std;
long long n,a[10005],cnt;
int main(){
cin>>n;
while(n!=1){
a[cnt++]=n;
if(n%2==0){
n/=2;
}
else{
n=n*3+1;
}
}
a[cnt]=1;
for(int i=cnt;i>=0;i--){
cout<<a[i]<<" ";
}
return 0;
}
0 comments
No comments so far...