Combinatorial Enumeration


Submit solution

Points: 2
Time limit: 2.0s
Memory limit: 256M

Problem type
Allowed languages
Python

From 1 to n, randomly select m integers from these n integers, and output all possible selection schemes.

Input Format

Two integers n, m, separated by a space on the same line.

Output Format

Output all schemes in ascending order, with one scheme per line.

  • First, the numbers in the same row are arranged in ascending order, and adjacent numbers are separated by a space.
  • Second, for two different rows, compare the numbers at corresponding positions one by one, with the row having the smaller lexicographical order (for example, 1 3 5 7 comes before 1 3 6 8).

Data Range

  • n > 0
  • 0 ≤ m ≤ n
  • n + (n - m) ≤ 25

Input Example

5 3

Output Example

1 2 3
1 2 4
1 2 5
1 3 4
1 3 5
1 4 5
2 3 4
2 3 5
2 4 5
3 4 5

```


Comments

There are no comments at the moment.