传送门UVa 729 - The Hamming Distance Problem
水啊。。
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
//freopen("input.txt", "r", stdin);
int n, a, b;
scanf("%d", &n);
while (n--)
{
scanf("%d%d", &a, &b);
string str1(a - b, '0');
string str2(b, '1');
str1 += str2;
cout << str1 << endl;
while (next_permutation(str1.begin(), str1.end()))
cout << str1 << endl;
if (n)
cout << endl;
}
return 0;
}