luogu#P4871. Oier们的镜子(mirror)
Oier们的镜子(mirror)
Background
Original by: b2019dy, disangan233.
is a very vain OIer, and he has some magical mirrors.
Problem Description
has objects in total, numbered . Among these objects, some are element plates and some are mirrors. An element plate contains elements, while a mirror has no elements at the beginning.
An element plate can correspond to at most one mirror. In that case, the mirror will carry the elements on that element plate.
A mirror cannot correspond to other mirrors.
You are now given the total number of objects and the number of elements each object has after correspondence. Please find how many different correspondence schemes there are.
Input Format
The first line: an integer , the total number of objects.
The second line: integers, representing the final number of elements of each object.
Output Format
Output the number of schemes modulo .
3
1 2 3
2
5
1 2 2 4 5
8
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, .
Sample Explanation
Because the problem setter is too lazy, in the explanation, "(the rest) are all element plates" is abbreviated as "suki", and "correspond" is abbreviated as .
Sample 1
- suki.
- .
The answer is: .
Sample 2
- suki.
- , suki.
- , suki.
- , suki.
- , suki.
- , ->.
- , suki.
- , ->.
The answer is: .
Translated by ChatGPT 5