Dynamic Programming: Bottom-Up (Tabulation, Knapsack)
You have n different coin values and may use each value any number of times. Count the number of distinct combinations of coins whose total is exactly T. Two combinations are the same if they use each value the same number of times, whatever the order. Print the count modulo 1000000007.
The first line has n and T. The second line has the n coin values.
Print one integer: the number of combinations modulo 1000000007.
1 <= n <= 100 0 <= T <= 10000 1 <= coin value <= 10000, all values distinct
1000 ms256 MB
3 5 1 2 5
4
The combinations are 5; 2+2+1; 2+1+1+1; and 1+1+1+1+1.
1 3 2
0
Three cannot be made from 2s.