Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <math.h>
- #include <string>
- #include <set>
- #include <cstdio>
- #include <iomanip>
- #include <map>
- using namespace std;
- int n, k;
- vector <int> ans;
- void gen_zero(int ind, int zero, int ones) {
- if (ind == n) {
- for (auto x : ans) cout << x;
- cout << endl;
- return;
- }
- if (zero + 1 + k <= n) {
- ans[ind] = 0;
- gen_zero(ind + 1, zero + 1, ones);
- }
- if (ones < k) {
- ans[ind] = 1;
- gen_zero(ind + 1, zero, ones + 1);
- }
- }
- int main()
- {
- cin >> n >> k;
- ans.resize(n);
- gen_zero(0, 0, 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement