#t340. 组合的输出
组合的输出
Output Combinations
Problem Description
Permutation and combination are common mathematical methods. A combination draws elements from elements (order does not matter, and ). We can simply understand the elements as the natural numbers , and take any of them.
Now you are asked to output all combinations.
For example, with , all combinations are:
.
Input Format
One line with two natural numbers .
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 . In C++ for example, you can use the following code:
cout << setw(3) << x;
This outputs the number in a field width of . 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