#include #include #include #define MAX 150000000 bool seen[MAX]; int unseen = 1; #define MAXD 100000 int delta[MAXD]; void mark(int n) { int k = unseen; int u = 1; while (k=MAX) { return; } if (d==MAXD) { fprintf(stderr, "#ouch\n"); exit(0); } if (delta[d]!=n && !seen[k+d]) { delta[d]=n; while (delta[u]==n) { u++; if (u==MAXD) { break; } } k+=d; break; } } } } int main() { memset(seen, 0, sizeof(seen)); memset(delta, 0, sizeof(delta)); for (int n=1; n<=10000; n++) { printf("%d %d\n", n, unseen); fflush(stdout); mark(n); while (seen[unseen]) { unseen++; if (unseen==MAX) { break; } } if (unseen==MAX) { break; } } return 0; }