#P16601. [SYSUCPC 2025] Ecosystem
[SYSUCPC 2025] Ecosystem
题目描述
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 types of animals in the ecosystem, and the -th type of animal consumes portions of bait per time. 's experiment was conducted over days, and on the -th day, portions of bait were deployed, with all bait being consumed each day. For each of the 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 .
输入格式
The first line contains two integers .
The second line contains integers, where the -th integer represents .
The third line contains integers, representing the amount of bait deployed on the -th day, .
输出格式
Output one line with integers, where the -th integer represents the answer for the -th day modulo .
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
提示
For the first day of the first sample, there are three possible eating sequences: , , and . The numbers in the sequences represent the types of animals.