Be sure about multiplication
cin>>toMake;
n = 100 * p;
sometimes it does not work as expected .
for input like
1 1 1 1 1 1 2.05
i found n = 204
So be sure of that
166 - Making Change
Moderator: Board moderators
-
- Learning poster
- Posts: 96
- Joined: Tue Apr 23, 2013 12:54 pm
Re: 166 - Making Change
Hi, there, just so you know this is a classic DP problem, the Change-making problem. You can find the solution for unlimited coins in the YT (YouTube), for the limited case, I recommend taking the most coins possible for each value. And you will need a prune strategy, since the amount of change grow until the maximum of coins available. I've used twice the smallest value for my AC code.