#P5598. 【XR-4】混乱度
【XR-4】混乱度
Description
Xiao X has balls of different colors. For the -th color, there are balls. Balls of the same color are indistinguishable. Define the disorder degree for colors as follows: line up all balls of colors in a row, and let be the total number of distinct arrangements modulo . Xiao X wants you to help compute the value of:
Input Format
The first line contains two integers .
The second line contains integers .
Output Format
Output one integer in one line, representing the answer.
2 2
1 2
3
4 7
1 2 8 9
28
15 5
1 5 26 1 0 5 0 6 7 51 1 5 26 1 0
124
Hint
[Sample 1 Explanation]
This problem uses bundled testdata.
- Subtask 1 (31 points): , is uniformly random in , time limit .
- Subtask 2 (32 points): , time limit .
- Subtask 3 (37 points): no special constraints, time limit .
For of the data, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号