Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Statement We all know how these magical devices work. People sit inside and count out your money and push it through the slot. You

Problem Statement

We all know how these magical devices work. People sit inside and count out your money and push it through the slot.

You need a job pretty bad and they are hiring! To test your skills they are going to give you a set of coins and a money amount, V, that they want. Your job is to find out the least amount of coins you can give them.

Your input is given as:
Q = number of quarters
D = number of dimes
N = number of nickels
P = number of pennies
V = target amount

Promise
V<100

Input Format

Q D N P V

Output Format

Minimum number of coins.

If you can't make change for the given number, output NO.

Sample Input

2 3 2 1 31

Sample Output

3

Explanation

You can give 31 cents in 3 coins. 1 quarter, 1 nickel, and 1 penny

Step by Step Solution

3.47 Rating (154 Votes )

There are 3 Steps involved in it

Step: 1

include include include using namespace std int main int qndpv cin q d n p v int c 0 if v25v int ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Entrepreneurship and Small Business Management

Authors: Norman M. Scarborough, Jeffrey R. Cornwall

8th edition

978-0133930382, 133849627, 133930386, 978-0133849622

More Books

Students also viewed these Economics questions