#include #include #include using namespace std; #define MAX (1LL<<34) bitset *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 binaryLength(long long n) { for (int w=0;; w++) { if (n==0) { return w; } else { n/=2; } } } int main() { seen = new bitset; long long p=0; for (long long n=0; n<=10000; n++) { long long v = other(v); cout << n << ' ' << binaryLength(p+v) << endl; p = v; } delete seen; seen = 0; return 0; }