Loading...
Loading...
Loading...
A parking machine takes coins of some values, as many of each as needed. Count the payments of an exact amount where the order of the coins matters, so inserting 1 then 2 differs from 2 then 1. Print the count.
Example 1
Input
1 2 3 4
Output
7
The seven orders are 1111, 112, 121, 211, 22, 13 and 31.
Example 2
Input
2 3
Output
0
Try the problem first. Open one hint at a time.
Now the amount loop is outside and the coin loop inside.
dp[a] adds dp[a - c] for every coin c that fits.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor