Given a coin system, with 1 and 0.01, greedily determine the change plan for some given values.
EXPLANATION:
Because we need to use as many larger coin as possible, we first sort the coins in decreasing order. And then, greedily select coins as many as possible.
It will be better if you use integers rather than decimals by multiplying all input values with 100.
AUTHOR’S AND TESTER’S SOLUTIONS:
Author’s solution can be found here.
Tester’s solution can be found here.
here in this problem why we need to add some fractional value while converting double into int. it has caused me a lot of WA
`double d;
cin>>d;
int x=(int)(d*100);`
double d;
cin>>d;
int x=(int)(d*100+.005);
both approach gives the same result on my machine but on submitting the first one gives WA.