Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <math.h>
  5. #include <string>
  6. #include <set>
  7. #include <cstdio>
  8. #include <iomanip>
  9. #include <map>
  10.  
  11. using namespace std;
  12.  
  13.  
  14.  
  15. int n, k;
  16. vector <int> ans;
  17. void gen_zero(int ind, int zero, int ones) {
  18.     if (ind == n) {
  19.         for (auto x : ans) cout << x;
  20.         cout << endl;
  21.         return;
  22.     }
  23.     if (zero + 1 + k <= n) {
  24.         ans[ind] = 0;
  25.         gen_zero(ind + 1, zero + 1, ones);
  26.     }
  27.     if (ones < k) {
  28.         ans[ind] = 1;
  29.         gen_zero(ind + 1, zero, ones + 1);
  30.     }
  31.  
  32. }
  33. int main()
  34. {
  35.     cin >> n >> k;
  36.     ans.resize(n);
  37.     gen_zero(0, 0, 0);
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement