Mr. Beast’s Generous Giveaway
Problem Statement:
YouTube has hired Mr. Beast to host their new event to support rising content creators. As usual, to make things impressive, Jimmy (Mr. Beast) decides to give-away $M in coins.
However, Jimmy’s bank only has coins of denominations in the array F.
Determine how many ways change can be made for amount $M. There are an infinite number of coins of each denomination
Example:
M = 4
F = {10,4,1,2}
There are 4 ways to make change for M: {4}, {1,1,1,1}, {2,1,1}, {2,2}.
Constraints:
- 1 ≤ Fi ≤ 50 (1 ≤ i ≤ X)
- 1 ≤ M ≤ 250
- 1 ≤ X ≤ 50
Input Format:
- The first line contains two space-separated integers and M, X where M is the amount to be given away and X is the number of coin denominations
- The second line contains space-separated integers that describe the values of each coin type.
Output Format:
- Print a single integer representing the number of ways to make the change
Sample input:
10 4 2 5 3 6 Sample output:
5