All binary strings of length n containing exactly k ones
Problem
Given numbers N and K print all strings of zeros and units of length N that contain exactly K units, in lexicographic order.
Input
Given 2 numbers: N and K (\(0 <= K <= N\) span>, \(0 <= N <= 100\)).
Imprint
It is necessary to output all strings of zeros and ones of length N that contain exactly K ones, in lexicographic order.
Examples
| # |
Input |
Output |
| 1 |
4 2 |
0011
0101
0110
1001
1010
1100
|