 Timer is Running

Find all distinct subset (or subsequence) sums
##### Submissions: 1638   Accuracy: 29.32%   Difficulty: Easy   Marks: 2

Given a set of integers, find distinct sum that can be generated from the subsets of the given sets and print them in an increasing order. It is given that sum of array elements is small.

Input:

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains an integer N denoting the size of array A.

The second line of each test case contains N space separated integers denoting elements of the array A[ ].

Output:

Print all the distinct sum that can be generated from the subsets in increasing order for each testcase in a new line.

Constraints:

1<= T <=100

1<= N <=100

1<= A[ ] <=100

Example:

Input:

1

5

2 3 4 5 6

Output:

0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Sujnesh Mishra
Author: sujnesh

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.