- 【例35.2】 角谷猜想
123
- 2025-3-24 10:38:39 @
#include<bits/stdc++.h> using namespace std; int n; int main(){ cin>>n; for(;n>1;){ if (n%2==0){ cout<<n<<"/2="<<n/2<<endl; n/=2; } else{ cout<<n<<"3+1="<<n3+1<<endl; n*=3; n++; } } cout<<"End"; return 0; }
1 comments
-
xiance066 LV 4 @ 2025-3-24 10:40:19Edited
#include<bits/stdc++.h> using namespace std; int n; int main(){ cin>>n; for(;n>1;){ if (n%2==0){ cout<<n<<"/2="<<n/2<<endl; n/=2; } else{ cout<<n<<"*3+1="<<n*3+1<<endl; n*=3; n++; } } cout<<"End"; return 0; }
码风有点丑,将就看吧
- 1
Information
- ID
- 123
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 6
- Tags
- # Submissions
- 27
- Accepted
- 12
- Uploaded By