#P16313. [ICPC 2023 Jinan R] 向未来说你好
[ICPC 2023 Jinan R] 向未来说你好
Problem Description
:::epigraph “Uh... um, can we restart our friendship?”
“What do you mean... you mean, start over?”
“...” :::
A long, long time ago, Xiaoqingyu and his best friend prepared a programming contest together. They prepared a total of problems, numbered with integers from to . The -th problem () has a difficulty rating .
Time flies. Fifteen months have passed since the contest they held. Xiaoqingyu is no longer an Informatics Olympiad contestant, but has transitioned into a coach. However, they once agreed to hold a series of tournaments together.
And Xiaoqingyu has not forgotten it.
Now, Xiaoqingyu wants to group these problems into several training sessions. To make sure the story background in the statements is consistent, Xiaoqingyu wants to partition these problems into several intervals. A partition scheme can be written as an integer sequence , meaning there are training sessions, where the -th session contains all problems with indices from to (both ends inclusive).
Besides, Xiaoqingyu does not want any session to be too unbalanced. If a session contains a hard problem, then this session should contain more problems. Formally, if problem is in the -th session (that is, ), then the inequality must hold.
Xiaoqingyu is curious about how many partition schemes can satisfy all the requirements above, and denotes the number by . This problem is very easy for him, so he computed the answer effortlessly.
On the day before these sessions, Xiaoqingyu suddenly realized that these problems were too hard for the contestants. Therefore, he came up with a new easy problem whose difficulty rating is only . He is curious: for each , if we define the sequence as follows, then what is the value of ?
$$a^{(j)}_i = \begin{cases}1 & i = j \\ a_i & \text{otherwise}\end{cases}$$Since the value of can be very large, you only need to output it modulo .
Input Format
Each test file contains only one set of testdata.
The first line contains an integer (), indicating the number of problems.
The second line contains integers (), where denotes the difficulty rating of the -th problem.
Output Format
Output one line containing integers separated by single spaces, where the -th integer is the value of modulo .
Please do not output extra spaces at the end of the line, otherwise your answer may be judged as wrong!
5
1 3 2 1 2
3 6 3 3 6
Hint
In the sample, for , we have . There are ways to assign the problems into sessions, as follows:
- ,
- ,
For , we have . There are ways to assign the problems into sessions, as follows:
- , ,
- , ,
- ,
- ,
- ,
For and , all schemes are the same as those when .
For , we have . There are ways to assign the problems into sessions, as follows:
- , ,
- ,
- , ,
- ,
- ,
Translated by ChatGPT 5