Approach hintTry it first, then revealHide
This counts combinations, not orderings, so put the coins in the outer loop and the amounts in the inner loop. Then dp[a] += dp[a - coin] builds each multiset of coins in exactly one order.
This counts combinations, not orderings, so put the coins in the outer loop and the amounts in the inner loop. Then dp[a] += dp[a - coin] builds each multiset of coins in exactly one order.