1 #include <iostream> 2 #include <sstream> 3 #include <string> 4 #include <algorithm> 5 #include <vector> 6 using namespace std; 7 8 #define GI ({int _t; scanf("%d", &_t); _t;}) 9 #define FOR(i, a, b) for (int i=a; i<b; i++) 10 #define REP(i, a) FOR(i, 0, a) 11 template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();} 12 int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;} 13 #define DBG(x) cout << #x << "::" << x << endl; 14 #define DBGV(_v) { REP(_i, _v.size()) { cout << _v[_i] << "\t";} cout << endl;} 15 16 int main() { 17 int a, b ; 18 while (scanf("%d%d", &a, &b) != -1 && a != 0) { 19 if (a>b) swap(a, b); 20 int res = 0, resnum=-1; 21 FOR(i, a, b+1) { 22 long long int num = i, len = 0; 23 do { 24 if (num%2==0) num/=2; 25 else num=3*num+1; 26 len++; 27 }while (num != 1); 28 if (len > res) { 29 resnum = i; 30 res = len; 31 } 32 } 33 printf("Between %d and %d, %d generates the longest sequence of %d values.\n", a, b, resnum, res); 34 } 35 return 0; 36 }