Loading...
Loading...
Loading...
A shop accepts coins of several values. Count the ways to pay an exact amount. Two ways are the same if they use the same coins in any order. Use a cached recursion.
Example
Input
11 1 5 10
Output
4
10+1, 5+5+1, 5+1x6 and 1x11 make 4 ways.
Try the problem first. Open one hint at a time.
Decide coin by coin: use the current coin again, or move to the next coin.
Exactly 0 left is one way. Negative, or no coins left, is zero.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor