BacktrackingRecursion
Given positive integers (the list may contain duplicates) and a target, find every unique combination that adds up to the target, using each element of the list at most once. Print each combination in ascending order on its own line, combinations in lexicographic order, or None if there are none. No combination may be printed twice.
Input
Line 1: n and the target. Line 2: n positive integers (duplicates possible).
Output
One combination per line, in lexicographic order, or None.
Constraints
1 <= n <= 14 1 <= each value <= 20 1 <= target <= 40
Example 1
Input
7 8 10 1 2 7 6 1 5
Output
1 1 6 1 2 5 1 7 2 6
Combinations summing to 8: 1 1 6, 1 2 5, 1 7 and 2 6.