fork download
  1. #include <stdio.h>
  2. int ubs(int x, int len)
  3. {
  4. if(x==1) return len;
  5. else if(x%2) return ubs(3*x+1,len+1);
  6. else return ubs(x/2,len+1);
  7. }
  8. int main()
  9. {
  10. int a,b;
  11. scanf("%d %d",&a,&b);
  12. int max, mn;
  13. for(int i=a;i<=b;i++)
  14. {
  15. int val=ubs(i,1);
  16. if(max<val)
  17. {
  18. max=val;
  19. mn=i;
  20. }
  21. }
  22. printf("%d %d",mn,max);
  23.  
  24. }
Success #stdin #stdout 0.01s 5276KB
stdin
1 10000
stdout
6171 262