#P8863. 「KDOI-03」构造数组
「KDOI-03」构造数组
Problem Description
You have an array of length . At the beginning, all are . You are given a target array of the same length . Determine how many different ways there are such that, after performing the following operation several times, array can be turned into .
- Choose two different indices , and increase both and by .
Two ways are considered different if and only if there exists some such that, in the -th operation, the chosen pair of indices in one way is different from that in the other way.
Take the answer modulo .
Input Format
Read input from standard input.
The input consists of two lines.
The first line contains a positive integer .
The second line contains positive integers, representing .
Output Format
Write output to standard output.
Output one line containing one positive integer, representing the number of ways to transform array into array using the operations, modulo .
4
2 2 2 2
90
Hint
[Sample 1 Explanation]
| Type ID | First group | Second group | Third group | Fourth group | Number of ways |
|---|---|---|---|---|---|
1<->2 |
3<->4 |
||||
1<->3 |
2<->4 |
||||
1<->4 |
1<->4 |
2<->3 |
2<->3 |
||
1<->2 |
3<->4 |
||||
1<->3 |
2<->4 |
||||
1<->3 |
1<->4 |
2<->3 |
2<->4 |
||
The total number of ways is .
[Sample 2]
See array/array2.in and array/array2.ans in the contestant files.
This sample satisfies the constraints of test points .
[Sample 3]
See array/array3.in and array/array3.ans in the contestant files.
This sample satisfies the constraints of test points .
[Sample 4]
See array/array4.in and array/array4.ans in the contestant files.
This sample satisfies the constraints of test points .
[Sample 5]
See array/array5.in and array/array5.ans in the contestant files.
This sample satisfies the constraints of test points .
[Sample 6]
See array/array6.in and array/array6.ans in the contestant files.
This sample satisfies the constraints of test points .
[Sample 7]
See array/array7.in and array/array7.ans in the contestant files.
This sample satisfies the constraints of test points .
[Constraints]
For of the data, , , and .
| Test point ID | ||
|---|---|---|
Translated by ChatGPT 5