挺简单的一道题
/* ID: yingzho1 LANG: C++ TASK: hamming */ #include <iostream> #include <fstream> #include <string> #include <map> #include <vector> #include <set> #include <algorithm> #include <stdio.h> #include <queue> #include <cstring> using namespace std; ifstream fin("hamming.in"); ofstream fout("hamming.out"); int N, B, D; int hamming(int l, int r) { int tmp = l ^ r; ; while (tmp) { ) ret++; tmp >>= ; } return ret; } int main() { fin >> N >> B >> D; ; vector<int> words; words.push_back(); ; num < ( << B); num++) { if (acount == N) break; ; for (; j < words.size(); j++) { if (hamming(num, words[j]) < D) break; } if (j == words.size()) { words.push_back(num); acount++; } } ; i < N; i++) { fout << words[i]; != && i != N-) fout << " "; else fout << endl; } ; }