#include <stdio.h> #include <string.h> #define MAX (1LL<<31) int main() { bool *sums = new bool[MAX]; memset(sums, 0, MAX*sizeof(*sums)); sums[0] = true; long long total = 0; long long limit = 1; long long n = 0; for (long long v=1;; v++) { while (limit < v+total) { limit *= 2; } bool keep = true; for (long long powerOf2=limit; powerOf2 >= v; powerOf2 /= 2) { if (powerOf2-v<MAX && sums[powerOf2-v]) { keep = false; break; } } if (keep) { for (long long o=total; o>=0; o--) { if (sums[o]) { if (o+v>=MAX) { long long n = 0; for (long long m=0; m<v; m++) { if (!sums[m]) { printf("%lld %lld\n", ++n, m); } } delete[] sums; return 0; } sums[o+v] = true; } } total += v; } } }