Approach hintTry it first, then revealHide
Let dp[a] be the fewest coins that make amount a; try every coin as the last one used and take the minimum, keeping unreachable amounts at infinity.
Let dp[a] be the fewest coins that make amount a; try every coin as the last one used and take the minimum, keeping unreachable amounts at infinity.