#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 4000000001LL #define WANTED 10000 unsigned char *K = 0; int main() { K = (unsigned char*)malloc(MAX); K[1]=1; K[2]=2; long long r=0; long long m=1; long long k=1; for (long long n=1; n<MAX; n++) { K[n] = k; r++; if (r==K[m]) { r=0; m++; k=k==1 ? 2 : 1; } } unsigned char inv[WANTED+1]; for (long long n=1; n<=WANTED; n++) { inv[n] = K[n]==1 ? 2 : 1; } long long o=2; for (long long w=1; w<=10000; w++) { while (memcmp(inv+1, K+o, w)) { o++; if (o+w>=MAX) { // the end return 0; } } printf("%lld %lld\n", w, o); fflush(stdout); } free(K); K=0; return 0; }