#include #include #include #define MAX 16000 bool seen[MAX]; long long other(long long n, long long p) { long long low = n; long long high = n; for (int z=0;; z++) { long long lo = low/p + ((low%p) ? 1 : 0); long long hi = high/p; for (long long v=lo; v<=hi; v++) { if (v > MAX) { fprintf(stderr, "*** the end\n"); fflush(stderr); exit(1); } if (!seen[v]) { return v; } } low = 2*low; high = 2*high + 1; } } int main() { long long v = 0; for (long long n=1; n<=10000; n++) { if (n==1) { v = 1; } else { v = other(n-1, v); } seen[v] = true; printf("%lld %lld\n", n, v); fflush(stdout); } return 0; }