Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- typedef long long LL;
- LL a[114514] = { 0 };
- int main(){
- int i = 0;
- LL m = -1;
- scanf("%lld", a);
- while(a[i]!=1){
- if(a[i] > m){
- m = a[i];
- }
- if(a[i] %2 == 1){
- a[i + 1] = 3 * a[i] + 1;
- }
- else{
- a[i + 1] = a[i]/2;
- }
- i += 1;
- }
- printf("1 ");
- while(i--){
- printf("%lld ", a[i]);
- }
- printf("\n%lld\n", m);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement