#P4495. [HAOI2018] 奇怪的背包
[HAOI2018] 奇怪的背包
Description
Xiao C is very good at knapsack problems. He has a strange knapsack with a parameter . After he puts some items into this knapsack, the knapsack’s weight is the total volume of the items modulo .
Now there are types of items with different volumes. The -th type has volume , and each type has an unlimited supply. He will make queries. For each query, a weight is given. You need to answer how many ways there are to put items so that the weight of an initially empty knapsack becomes . Note that two ways are considered different if and only if the types of items used are different, regardless of how many of each type are used. It is not hard to see that the total number of ways is .
Since the answer may be large, you only need to output it modulo .
Input Format
The first line contains three integers , as described above.
The next line contains integers denoting .
The next line contains integers denoting .
Output Format
Output lines, each containing one integer, the answer for that query.
3 3 6
1 3 4
5 2 3
5
6
6
Hint
HAOI2018 round1 T1
Translated by ChatGPT 5
京公网安备 11011102002149号