// @BEGIN_OF_SOURCE_CODE /* @JUDGE_ID: 17243NT 180 C++ "Simulation" */ // Send to judge@uva.es #include #include #include #ifdef ONLINE_JUDGE #define ins cin #define outs cout #else #define ins fin #define outs fout ifstream fin("myprog.in"); ofstream fout("myprog.out"); #endif int winnerccw(int ntotal); int winnercw(int ntotal); int main() { int i, nmin, nmax; int ccw[510], cw[510]; for(i = 0; i <= 500; i++) { ccw[i] = winnerccw(i); cw[i] = winnercw(i); } while(ins >> nmin >> nmax) { bool win[510]; if(nmin == 0 || nmax == 0) break; for(i = 0; i <= nmax; i++) win[i] = false; for(i = nmin; i <= nmax; i++) { win[ccw[i]] = true; win[cw[i]] = true; } for(i = 1; i <= nmin / 2; i++) if(!win[i]) break; if(i > nmin / 2) outs << "Better estimate needed\n"; else outs << i << endl; } return 0; } int winnerccw(int ntotal) { int i, j, cur, next; int eeny[510]; next = 0; for(i = 0; i < ntotal; i++) eeny[i] = i; for(i = ntotal; i > 0; i--) { next = (next + 14) % i; cur = eeny[next]; for(j = next + 1; j < i; j++) eeny[j - 1] = eeny[j]; } return cur; } int winnercw(int ntotal) { int i, j, cur, next; int eeny[510]; next = 0; eeny[0] = 0; for(i = 1; i < ntotal; i++) eeny[i] = ntotal - i; for(i = ntotal; i > 0; i--) { next = (next + 14) % i; cur = eeny[next]; for(j = next + 1; j < i; j++) eeny[j - 1] = eeny[j]; } return cur; } // @END_OF_SOURCE_CODE