由题意可知,0肯定是会出现的,因为它最小,然后遍历一遍找出来的肯定是最小的,
对每个数的判断可以采用移位操作;
code:
/*
ID: yueqiq
LANG: C++
TASK: hamming
*/
#include <set>
#include <map>
#include <ctime>
#include <queue>
#include <cmath>
#include <stack>
#include <limits>
#include <vector>
#include <bitset>
#include <string>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <string.h>
#include <iostream>
#include <algorithm>
#define ls rt<<1
#define rs rt<<1|1
#define Si set<int>
#define LL long long
#define pb push_back
#define PS printf(" ")
#define Vi vector<int>
#define LN printf("\n")
#define SD(a) scanf("%d",&a)
#define PD(a) printf("%d",a)
#define SET(a,b) memset(a,b,sizeof(a))
#define FF(i,a) for(int i(0);i<(a);i++)
#define FD(i,a) for(int i(a);i>=(1);i--)
#define FOR(i,a,b) for(int i(a);i<=(b);i++)
#define FOD(i,a,b) for(int i(a);i>=(b);i--)
#define readf freopen("hamming.in","r",stdin)
#define writef freopen("hamming.out","w",stdout)
const double pi = acos(-1.0);
const int maxn = 50;
const int BigP = 99999999;
const int INF = 99999999;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
using namespace std;
int N,B,D;
bool check(int a,int b){
int cnt=0;
while(a||b){
//printf("%d %d \n",a&1,b&1);
if((a&1)!=(b&1)){
cnt++;
if(cnt>=D) return true;
}
a>>=1;
b>>=1;
}
if(cnt>=D) return true;
return false;
}
int res[50],cnt=1;
int main(){
readf;
writef;
SD(N);SD(B);SD(D);
res[1]=0;
for(int i=1;i<(1<<B);i++){
bool ok=true;
FOR(j,1,cnt)
if(!check(i,res[j])){
//printf("%d %d\n",i,res[j]);
ok=false;
break;
}
if(ok){
cnt++;
res[cnt]=i;
}
if (cnt==N) break;
}
FOR(i,1,cnt){
PD(res[i]);
if ((i%10==0)||(i==cnt)) LN;
else PS;
}
return 0;
}