luogu#P16601. [SYSUCPC 2025] Ecosystem

    ID: 16694 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>2025背包 DP矩阵加速进制高校校赛

[SYSUCPC 2025] Ecosystem

Problem Description

Dr.Orange\texttt{Dr.Orange} is conducting research in animal psychology, and one of the studies involves inferring the number of each animal in the ecosystem based on their dietary habits. It is known that there are nn types of animals in the ecosystem, and the ii-th type of animal consumes aia_i portions of bait per time. Dr.Orange\texttt{Dr.Orange}'s experiment was conducted over mm days, and on the ii-th day, tit_i portions of bait were deployed, with all bait being consumed each day. For each of the mm days, different animals take turns to consume bait. You need to answer how many different eating sequences. Two sequences are the same only if the animals at each position in the sequence are of the same species. Since this result can be very large, please provide the answer modulo 109+710^9+7.

Input Format

The first line contains two integers n,m(1n,m100)n, m(1\le n,m\le 100).

The second line contains nn integers, where the ii-th integer represents ai(1ai100)a_i(1\le a_i\le 100).

The third line contains mm integers, representing the amount of bait deployed on the ii-th day, ti(1ti109)t_i(1\le t_i\le 10^9).

Output Format

Output one line with mm integers, where the ii-th integer represents the answer for the ii-th day modulo 109+710^9+7.

5 3
5 4 4 2 3
5 8 3
3
16
1
10 5
9 1 6 5 10 4 9 2 7 6
64 92 43 30 2
566507809
840913760
608266829
85862862
2

Hint

For the first day of the first sample, there are three possible eating sequences: [1][1], [4,5][4,5], and [5,4][5,4]. The numbers in the sequences represent the types of animals.