Lotto
Time limit1sMemory limit128 MB
For each set of k numbers in ascending order, print all 6-element subsets in lexicographic order, separated by blank lines.
- Level
Medium4 of 10
- Topics
- Backtracking, Recursion, Combinatorics
- Solved
- No attempts yet
Problem
In the German lotto, you choose 6 distinct numbers from .
One popular strategy for picking lotto numbers is to first choose numbers () out of the 49 to form a set , and then pick the 6 numbers only from within .
For example, if and , there are 28 different ways to choose 6 numbers from this set.
Given a set and , write a program that prints every way to choose 6 numbers from .
Input
The input consists of several test cases. Each test case is given on a single line. The first number on the line is (), followed by the numbers that make up the set . The elements of are given in ascending order.
The last line of the input contains a single and is not processed.
Output
For each test case, print every way to choose 6 numbers from in lexicographic order. Each way is printed on its own line as the 6 chosen numbers in ascending order, separated by single spaces.
Print one blank line between the outputs of consecutive test cases.