3 5 1000000007 1 2 5
The unordered ways are 5, 2+2+1, 2+1+1+1, and five 1s, so the answer is 4.
4
2 3 17 2 4
No combination forms target 3, so the answer is 0.
0
4 0 97 2 3 5 7
There is exactly one way to form target 0: choose no coins.
1
Given coin values, a target, and a modulus mmm, count the number of unordered ways to form the target. Each coin value may be used any number of times.