Correct Change I
You are given a certain number of
pennies and a desired
sum of cents. Is it possible to select the exact change to reach that sum?
You will be given three numbers as input -
true if you can select coins to reach
sum exactly, and
In this challenge, you can be given any number of
nickels but only 0 to 4
Image from Wikipedia
Note: A nickel is worth 5 cents. A penny is worth 1 cent.
Boilerplate code is provided for Java. For other languages, read in the numbers from the standard input in the following format.
- The input starts with N, the number of cases.
- N lines follow, which each contains 3 integers in order for the number of
nickels, number of
pennies, and the desired
Print out true or false to the output for each case on its own line.
Click on "View Raw I/O" below to view sample input and output.