Dynamic programming: find possible sums of given digits to reach given sum

72 Views Asked by At

Maybe anyone has idea how to solve this problem using dynamic programming: I have a natural number. Let’s name it n. Then, have digits: 1, 3, 4. I have to find all possible sums (with repetitives) of n using digits above. For example.

n=3. Then solution:
1+1+1=3
3=3

I know how to solve this problem using recursion or loops, but I really have no idea how to solve it with dynamic programming. And how to write relation for subproblems.

1

There are 1 best solutions below

0
On

Hint: condition on the first element in the sum.