#t340. 组合的输出

组合的输出

Output Combinations

Problem Description

Permutation and combination are common mathematical methods. A combination draws rr elements from nn elements (order does not matter, and r≤nr \le n). We can simply understand the nn elements as the natural numbers 1,2,…,n1,2,\dots,n, and take any rr of them.

Now you are asked to output all combinations.

For example, with n=5,r=3n=5, r=3, all combinations are:

123,124,125,134,135,145,234,235,245,345123,124,125,134,135,145,234,235,245,345.

Input Format

One line with two natural numbers n,r  (1<n<21,  0≤r≤n)n,r\;(1<n<21,\;0 \le r \le n).

Output Format

All combinations, each combination on its own line with its elements in ascending order, and each element occupying three character positions; all combinations are also in lexicographic order.

Note! When outputting, each number needs a field width of 33. In C++ for example, you can use the following code:

cout << setw(3) << x;

This outputs the number xx in a field width of 33. Note you need the header iomanip.

Sample Input

5 3

Sample Output

  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