#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX (1<<29) int *a = 0; #define WANTED 1000 long long first[WANTED]; int u = 0; int main() { for (int w=0; w<WANTED; w++) { first[w] = -1; } a = (int*)malloc(MAX * sizeof(*a)); for (long long n=1; n<(1LL<<60); n++) { long long m = n; int v = 0; while (m>1) { v++; if (m%2==0) { m /= 2; } else { m = (m ^ (2*m)) - 1; } if (m<n && m<MAX) { v+=a[m]; break; } } if (n<MAX) { a[n] = v; } if (v<WANTED && first[v]<0) { first[v] = n; while (u<WANTED && first[u]>=0) { printf("%d %lld\n", u, first[u]); fflush(stdout); u++; if (u==WANTED) { break; } } } } free(a); a = 0; return 0; }