Here is a problem: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&page=show_problem&problem=36
It hasn't said that it is going to give us the number of inputs at first! so how should I handle the input. I used hasNextInt() but got time limit.
Thanks in Advance for Your Help...
public class Main {
public static void main(String[] args) {
int a,b,x,max=0,count;
Scanner in = new Scanner(System.in);
while(in.hasNextInt())
{
a = in.nextInt();
b = in.nextInt();
max = 0;
count = 1;
for(int i=a;i<=b;i++)
{
x=i;
count = 1;
while(true)
{
if(x == 1)
break;
if(x%2 == 0)
x = x/2;
else
x = 3*x+1;
count++;
}
if(count>max)
max = count;
}
System.out.println(a+" "+b+" "+max);
}
}
}

