# find all distinct sums

Given a sum total and list of n positive integers find all distinct sums that add up to sum total. For example if the given sum total is 5 and given list of 6 integers [1 4 5 3 2 3] , the sum 5 can be formed by adding 5, 1 + 4, 3 +2 and 2+3. Hence there 4ways to sum whose equal to 5.

*find all distinct sums*

*Second test case for more details*

* If sum=4 , n =6 , and the list is [4, 3, 2, 2, 1, 1], then there are four different sums that equal 4: 4, 3+1, 2+2, and 2+1+1. *

Ref:

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=515

## Leave a Reply