#include <bitset> #include <iostream> #include <stdlib.h> using namespace std; #define MAX (1LL<<34) bitset<MAX> *seen = 0; long long avoid(long long x, long long i) { long long v=0; long long b=1; while (i) { if (x & 1) { } else { if (i & 1) { v+=b; } i/=2; } x/=2; b*=2; } return v; } long long other(long long p) { seen->set(p); for (long long i=1;; i++) { long long v=avoid(p, i); if (v>=MAX) { exit(0); } if (!seen->test(v)) { return v; } } } int main() { seen = new bitset<MAX>; long long p=0; for (long long n=0; n<=10000; n++) { long long v = other(v); cout << n << ' ' << p+v << endl; p = v; } delete seen; seen = 0; return 0; }