- hello world
sss
- @ 2026-3-18 20:43:33
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,arr[1010];
cin>>n;
int i=1;
arr[i] = n;
while(n>1){
i++;
if(n%2==0){
arr[i]=n/2;
n=n/2;
}else{
arr[i]=n*3+1;
n=n*3+1;
}
}
for(int j=i;j>=1;j--){
cout<<arr[j]<<" ";
}
return 0;
}
0 条评论
目前还没有评论...
信息
- ID
- 1
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 3
- 标签
- 递交数
- 64
- 已通过
- 33
- 上传者