/* -*- coding: utf-8 -*- * * 1152.cc: No.1152 10億ゲーム - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 10; /* typedef */ typedef long long ll; typedef vector vi; typedef queue qi; typedef pair pii; /* global variables */ int e2s[MAX_N], e5s[MAX_N]; /* subroutines */ inline void getpos(int &x, int &y) { int p; scanf("%d", &p); x = y = 0; while (p % 2 == 0) x++, p /= 2; while (p % 5 == 0) y++, p /= 5; } inline void putpos(int x, int y) { printf("%d\n", e2s[x] * e5s[y]); fflush(stdout); } inline bool getputpos(int ax, int ay, int &bx, int &by) { putpos(ax, ay); if (ax == bx && ay == by) return true; getpos(bx, by); return (ax == bx && ay == by); } inline int hdist(int x0, int y0, int x1, int y1) { return abs(x1 - x0) + abs(y1 - y0); } /* main */ int main() { e2s[0] = e5s[0] = 1; for (int i = 1; i < MAX_N; i++) { e2s[i] = e2s[i - 1] * 2; e5s[i] = e5s[i - 1] * 5; } int ax, ay, bx, by; getpos(ax, ay); getpos(bx, by); while (ax != 7 || ay != 9) { if (ax < 7) ax++; else if (ax > 7) ax--; else if (ay < 9) ay++; if (getputpos(ax, ay, bx, by)) return 0; } if (hdist(ax, ay, bx, by) & 1) { for (int i = 0; i < 2; i++) { ax++; if (getputpos(ax, ay, bx, by)) return 0; } } else { ax += 2; if (getputpos(ax, ay, bx, by)) return 0; } for (;;) { int dx = ax - bx, dy = ay - by; if (dx >= dy) ax--; else ay--; if (getputpos(ax, ay, bx, by)) break; } return 0; }