#P3230. [HNOI2013] 比赛
[HNOI2013] 比赛
Description
Momo loves watching soccer matches, but she missed the latest league because she was addicted to an archery game. There are teams in the league, and the rules are as follows:
- Every pair of teams plays exactly one match.
- If a match ends in a draw, each team gets point.
- Otherwise, the winner gets points and the loser gets points.
Although she could not watch the exciting matches, Momo learned from the news the final total points of each team. Now she wants to compute how many possible tournament outcomes are consistent with these totals.
For example, if there are teams and each team finishes with points, then there are two possibilities:
Possibility and Possibility
| Team | Points | Team | Points | ||||||
|---|---|---|---|---|---|---|---|---|---|
| - | - | ||||||||
| - | - | ||||||||
| - | - |
Since the answer can be large, output it modulo .
Input Format
The first line contains a positive integer , the number of teams.
The second line contains non-negative integers, giving the final total points of each team in order.
Output Format
Output a single integer, the answer modulo .
4
4 3 6 4
3
Hint
- of the testdata satisfies .
- of the testdata satisfies .
- of the testdata satisfies .
- of the testdata satisfies , and there exists at least one solution.
Translated by ChatGPT 5
京公网安备 11011102002149号