#include #include #pragma warning( disable: 4996 ) #pragma warning( error: 4717 ) template< class T > T Max( T a, T b ) { return a > b ? a : b; } template< class T > void SwapValues( T& a, T& b ) { T temp( a ); a = b; b = temp; } static const int MAX_SIZE = 100000001; static unsigned short cycle[ MAX_SIZE ]; unsigned short SequenceLength( unsigned int val ) { if ( val < MAX_SIZE && cycle[ val ] != 0 ) { return cycle[ val ]; } val = val % 2 != 0 ? (((val << 1) | 1) + val ) : val / 2; return SequenceLength( val ) + 1; } unsigned short Process( int start, int end ) { unsigned short bestLength = 0; for ( int i = start; i <= end; i++ ) { if ( cycle[ i ] == 0 ) { cycle[ i ] = SequenceLength( i ); } bestLength = Max( bestLength, cycle[ i ] ); } return bestLength; } int main( int argc, char* argv[] ) { cycle[ 1 ] = 1; while ( true ) { int start, end; bool eof = scanf( "%i %i", &start, &end ) == EOF; if ( eof ) { break; } if ( start > end ) { unsigned short maxCycle = Process( end, start ); printf( "%i %i %i\n", start, end, maxCycle ); } else { unsigned short maxCycle = Process( start, end ); printf( "%i %i %i\n", start, end, maxCycle ); } } return 0; }