2 solutions
- 1
Information
- ID
- 1807
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 18
- Accepted
- 14
- Uploaded By
水一道题
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
cout<<n<<" ";
while(n>1)
{
if(n%2!=0)
{
n=n*3+1;
cout<<n<<" ";
}
else
{
n/=2;
cout<<n<<" ";
}
}
return 0;
}
By signing up a Hydro universal account, you can submit code and join discussions in all online judging services provided by us.