1.

/**
* FWP, Ausgew�hlte Probleme aus dem ACM Programming Contest, WS09
* Problem: 371 Ackermann functions
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=307
*
* @author Felix Dietrich
* @version 1.0, 10/23/2009
*
* Method : Bruteforce
* Status : Accepted
* Runtime: 0.332
*/

import java.util.Scanner;


class Main
{
public static void main(String... s)
{
Scanner sc = new Scanner(System.in);

int min, max, num, maxvalue, temp, temp2;

while(sc.hasNext())
{
min = sc.nextInt();
max = sc.nextInt();

if(min == 0 && max == 0)
return;

num = min;
// set min and max in the right order
if(max < min)
{
temp = max;
max = min;
min = temp;
}
maxvalue = -1;

// loop through the numbers and get the maximum out of them
for(int i=min; i<=max; i++)
{
temp = 0;
temp2 = i;
// calc the collatz series counting the parts
do
{
if(temp2 % 2 == 0)
temp2 /= 2;
else
temp2 = temp2*3+1;
temp++;
}while(temp2 > 1);

if(temp > maxvalue)
{
maxvalue = temp;
num = i;
}
}

System.out.println("Between " + min + " and " + max + ", " + num + " generates the longest sequence of " + maxvalue + " values.");
}
}


}