#include #include using namespace std; int step(int c){ if (c%2 == 0){ return c/2; } return 3*c+1; } int main(){ int a, b, x, y; int * pole1 = new int[100000000]; while(1){ scanf("%d", &a); scanf("%d", &b); if (a == 0 && b == 0) break; x = a; y = b; int i; for (i=0; i < 100000000; ++i){ pole1[i] = -1; } int steps_x = -1; int steps_y = -1; while(1){ ++steps_x; pole1[x] = steps_x; if (x == 1){break;} x = step(x); } while(1){ ++steps_y; if (pole1[y] != -1){break;} y = step(y); } printf("%d needs %d steps, %d needs %d steps, they meet at %d\n", a, pole1[y], b, steps_y, y); } delete [] pole1; return 0; }