DP approach for the coin problem.