#P2840. 纸币问题 2
纸币问题 2
Background
You are a very rich kid.
Problem Description
You have types of banknotes with pairwise distinct denominations. The -th type has denomination , and there are infinitely many banknotes of each type. Now you need to pay an amount of . Find how many ways there are to pay exactly , and output the answer modulo .
Note that here, the same multiset of banknotes is considered different if the payment order is different. For example, to pay , using one banknote of value and one banknote of value produces two ways ( and ).
Input Format
The first line contains two positive integers , representing the number of banknote types and the target amount.
The second line contains positive integers separated by spaces, representing the denominations of the types of banknotes.
Output Format
Output one integer per line, representing the number of payment ways.
6 15
1 5 10 20 50 100
42
3 15
1 5 11
39
Hint
For of the testdata, and .
For of the testdata, and .
In fact, the kid is not that rich.
Translated by ChatGPT 5