#P2840. 纸币问题 2

纸币问题 2

Background

You are a very rich kid.

Problem Description

You have nn types of banknotes with pairwise distinct denominations. The ii-th type has denomination aia_i, and there are infinitely many banknotes of each type. Now you need to pay an amount of ww. Find how many ways there are to pay exactly ww, and output the answer modulo 109+710^9+7.

Note that here, the same multiset of banknotes is considered different if the payment order is different. For example, to pay 33, using one banknote of value 11 and one banknote of value 22 produces two ways (1+21+2 and 2+12+1).

Input Format

The first line contains two positive integers n,wn, w, representing the number of banknote types and the target amount.

The second line contains nn positive integers a1,a2,ana_1, a_2, \dots a_n separated by spaces, representing the denominations of the nn 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 40%40\% of the testdata, n10n \le 10 and w100w \le 100.

For 100%100\% of the testdata, 1n1031 \le n \le 10^3 and 1ai,w1041 \le a_i, w \le 10^4.

In fact, the kid is not that rich.

Translated by ChatGPT 5