#include #include #include using namespace std; // values with Hammingweight 2 unordered_set seen; // free bits long long nbFreeBits = 0; long long freeBits[6]; // encode long long encode(long long x, long long y) { if (x > y) { return (x<<32) + y; } else { return (y<<32) + x; } } void notice(long long x) { freeBits[nbFreeBits++] = x; } void remove(long long x) { for (long long k=0; k= 3) { // next value has Hamming weight 3, this was unexpected cerr << "# a(" << n << ") has 3 bits!" << endl; break; } v = next2++; } else { seen.insert(v); cout << ++k << ' ' << (vi > vj ? vi : vj)-1 << endl; if (k==10000) { break; } remove(vi); remove(vj); } // remember this value a[n] = v; // new free bits? if ((n & 1)==0) { long long high = a[n/2] >> 32; long long low = a[n/2] & 0xFFFFFFFF; if (high) { notice(high); } if (low) { notice(low); } } } delete[] a; return 0; }