Medium Accuracy: 33.99% Submissions: 17686 Points: 4
Given an array of integers A and a sum B, find all unique combinations in A where the sum is equal to B. The same repeated number may be chosen from A unlimited number of times.
Note: 1. All numbers will be positive integers. 2. Elements in a combination (a1, a2, … , ak) must be in non-descending order. (ie, a1 ≤ a2 ≤ … ≤ ak). 3. The combinations themselves must be sorted in ascending order.
First line of input contains number of testcases T. For each testcase, there will be three lines of input, first of which contains N, size of array. Next line contains N space seperated integers, and the last line contains B.
For each testcase, print the sets enclosing a backet "(" and ")". No space between two sets. If no set can be formed with the given set, then print "Empty" (without quotes).
1 <= T <= 500
1 <= N <= 12
1 <= A[i] <= 9
1 <= B <= 30