#C14336. Combination Sum
Combination Sum
Combination Sum
Given a set of unique positive integers and a target sum (T), find all unique combinations where the chosen numbers sum up to (T). Each number from the set may be used an unlimited number of times. In each combination, the numbers should appear in non-decreasing order. If no valid combination exists, output exactly []
.
For example, when (T = 7) and the set is [2, 3, 6, 7], the valid combinations are ([2, 2, 3]) and ([7]).
inputFormat
Input is read from standard input (stdin). The first line contains a single integer representing the target sum (T). The second line contains space-separated positive integers representing the candidate numbers.
outputFormat
Output to standard output (stdout). For each valid combination, print a single line with the numbers separated by a single space. The order of combinations can be arbitrary. If no combination exists, print exactly []
.## sample
7
2 3 6 7
2 2 3
7
</p>