- #include <bits/stdc++.h>
- using namespace std;
- vector <int> Ham;
- int n;
- int main(){
- int t, p, f = 0, bl = 0;
- scanf("%d", &t);
- while(t--){
- scanf("%d %d", &n, &p);
- int b = n-p;
- while(p--)Ham.push_back(1);
- while(b--)Ham.push_back(0);
- reverse(Ham.begin(), Ham.end());
- if(bl)puts(""); bl = 1;
- for(int i = 0; i < n; i++)cout << Ham[i];
- puts("");
- while(next_permutation(Ham.begin(), Ham.end())){
- for(int i = 0; i < n; i++)cout << Ham[i];
- puts("");
- }
- Ham.clear();
- }
- return 0;
- }
Sunday, June 7, 2015
UVa - 729 - The Hamming Distance Problem
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment