#include #include using namespace std; int next(int n) { if (n % 2 == 0) { return n/2; } else { return 3*n + 1; } } int main(int argc, char** argv) { while (true) { map mapa; int a, b, aa, bb; scanf("%d %d", &a, &b); if ((a==0) && (b==0)) break; aa = a; bb = b; int citac = 0; while (a!=1) { mapa[a]=citac++; a = next(a); } citac = 0; map::iterator it; while (b!=1) { it = mapa.find(b); if (it!=mapa.end()) { break; } b = next(b); citac++; } printf("%d needs %d steps, %d needs %d steps, they meet at %d\n", aa, it->second, bb, citac, it->first); } return 0; }