AlgoUniversity
  • Go Back
Discussion
Ways To Make Coin Change :

Author

Nikunj Nawal

Difficulty Level : Easy

Submissions : 207

Asked In :

Marks :10

: 4 | : 1

You are given an infinite supply of coins of each denomination $$$D = \{D_0, D_1, D_2,......, D_{n-1}\}$$$. You need to figure out the total number of ways $$$W$$$, in which you can change value $$$V$$$ using coins of denominations from $$$D$$$. Print $$$0$$$ if a change isn't possible.

Input

The first input line contains an integer $$$N$$$ $$$(1 \le N \le 10)$$$ — representing the total number of denominations.

The second input line contains $$$N$$$ integer values separated by a single space. The $$$i^{th}$$$ integer value represents the denomination value $$$D_i$$$ $$$(1 \le D_i \le 10^5)$$$. All $$$D_i$$$(s) are distinct.

The third line of input contains the value of $$$V$$$ $$$(1 \le V \le 2*10^3)$$$ — representing the value for which the change needs to be generated.

Output

For each test case, print an integer denoting the total number of ways W, in which a change for V is possible.

Examples

Input
2
30 70
50
Output
0
Input
3
1 1500 1000
2000
Output
4

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.