Advertisement
wojiaocbj

Untitled

Jun 15th, 2022
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. typedef long long LL;
  3. LL a[114514] = { 0 };
  4. int main(){
  5.     int i = 0;
  6.     LL m = -1;
  7.     scanf("%lld", a);
  8.     while(a[i]!=1){
  9.         if(a[i] > m){
  10.             m = a[i];
  11.         }
  12.         if(a[i] %2 == 1){
  13.             a[i + 1] = 3 * a[i] + 1;
  14.         }
  15.         else{
  16.             a[i + 1] = a[i]/2;
  17.         }
  18.         i += 1;
  19.     }
  20.     printf("1 ");
  21.     while(i--){
  22.         printf("%lld ", a[i]);
  23.     }
  24.     printf("\n%lld\n", m);
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement