Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int n, m, k, cnt = 0;
  4. int a[10005];
  5. void Try(int i, int cur)
  6. {
  7.     if (i == n)
  8.     {
  9.         cnt++;
  10.         if (cnt == m)
  11.         {
  12.             for (int j = 0; j < n; ++j)
  13.             {
  14.                 cout << a[j] << ' ';
  15.             }
  16.         }
  17.         return;
  18.     }
  19.     if (cur < k - 1)
  20.     {
  21.         a[i] = 0;
  22.         Try(i + 1, k + 1);
  23.     }
  24.     a[i] = 1;
  25.     Try(i + 1, 0);
  26. }
  27. int main()
  28. {
  29.     ios::sync_with_stdio(0);
  30.     cin.tie(0);
  31.     cin >> n >> m >> k;
  32.     Try(0, 0);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement