Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ or Java Denominations You are working at a cash counter at walmart and you have infinite number of 3 , 5 and 10 denomination

C++ or Java

Denominations

You are working at a cash counter at walmart and you have infinite number of 3, 5 and 10 denomination coins. Can you determine the number of ways of making change for a particular number of units using the given types of coins?

Input: The first line contains an Integer T, the number of test cases. Next T lines contain a single integer N.

Output: For each test case, print the number of ways you can form a sum of N by using the coin denominations.

Constraints: 1T103 0N106

Sample Input

2 20 13 

Sample Output

4 2

Explanation

Case 1: N=20. There are 4 ways to make a sum of 20 using 3, 5 and 10 denomination coins. They are (10, 10), (5, 5, 10), (5, 5, 5, 5), (3, 3, 3, 3, 3, 5) Case 2: N=13. There are 2 ways to make a sum of 20 using 3, 5 and 10 denomination coins. They are (3, 5, 5), (3, 10)

Note: Your code should be able to convert the sample input into the sample output. However, this is not enough to pass the challenge, because the code will be run on multiple test cases. Therefore, your code must solve this problem statement.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Distributed Relational Database Architecture Connectivity Guide

Authors: Teresa Hopper

4th Edition

0133983064, 978-0133983067

More Books

Students also viewed these Databases questions

Question

What did they do? What did they say?

Answered: 1 week ago