1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#include <cstdio> #include <cstring> #include <algorithm> #include <cstdlib> #include <string> #include <vector> using namespace std;
typedef long long LL; const int maxn = 65; int a[maxn];
int main() { freopen("hamming.in", "r", stdin); freopen("hamming.out", "w", stdout); int n, b, d, p = 0, cnt = 0; scanf("%d%d%d", &n, &b, &d); putchar('0'); for (int i = 1; i < n; ++i) { bool ok = false; while (!ok) { bool flag = true; for (int j = 0; j < i; ++j) { if (__builtin_popcount(p ^ a[j]) < d) { flag = false; break; } } if (flag) { ok = true; break; } ++p; } a[i] = p; ++cnt; printf("%c%d", cnt % 10 ? ' ' : '\n', p++); } puts(""); return 0; }
|