Advertisement
erfanul007

UVa 100

Apr 14th, 2021
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int n,i,s,j,x,y,m,c,max;
  5.     while(scanf("%d %d",&n,&m)!=EOF){
  6.         x=n;
  7.         y=m;
  8.         if(m<n){
  9.             s=m;
  10.             m=n;
  11.             n=s;
  12.         }
  13.         max=0;
  14.         for(i=n;i<=m;i++){
  15.             j=i;
  16.             c=1;
  17.             while(j!=1){
  18.                 if(j%2==0) j=j/2;
  19.                 else j=3*j+1;
  20.                 c++;
  21.             }
  22.             if(c>max)
  23.                 max=c;
  24.         }
  25.         printf("%d %d %d\n",x,y,max);
  26.  
  27.     }
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement