[UVa] 100 – The 3n+1 Problem - http://kuoe0.ch/18/uva-100-the-3n-plus-1-problem/
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
long long int MAX;
long long int count( int x ) {
if ( x == 1 )
return 0;
return count( x == 1 ? 3 * x + 1 : ( x >> 1 ) ) + 1;
}
int main() {
int a, b;
while ( ~scanf( "%d %d", &a, &b ) ) {
printf( "%d %d", a, b );
if ( a > b )
swap( a, b );
MAX = 0;
for ( int i = a; i < = b; ++i )
MAX = max( MAX, count( i ) + 1 );
printf( " %lldn", MAX );
}
return 0;
}