3 条题解
-
112203沈宇阳 (12203沈宇阳) LV 8 @ 2021-11-06 13:19:52
#include<iostream>
using namespace std;
int main()
{
int x,cnt=0;
cin >> x;
while(x!=1)
{
if(x%2==0)
{
x=x/2;
}
else{
x=3*x+1;
}
cnt++;
}
cout<<cnt<<endl;
return 0;
}/ -
02024-02-25 17:45:16@
#include<bits/stdc++.h> using namespace std; int main() { int n,cnt=0; scanf("%d",&n); while(n!=1) { if(n%2==0) n/=2; else n=3*n+1; cnt++; } printf("%d",cnt); return 0; }
-
02022-01-29 10:40:46@
#include <cstdio> int main(){ int x; scanf("%d",&x); int res=0; while (x!=1){ if (x&1) x=(3*x+1)>>1,res+=2; else x>>=1,++res; } printf("%d\n",res); }
- 1
信息
- ID
- 1493
- 难度
- 1
- 分类
- (无)
- 标签
- 递交数
- 58
- 已通过
- 48
- 通过率
- 83%
- 上传者