#P5641. 【CSGRound2】开拓者的卓识
【CSGRound2】开拓者的卓识
Background

(The picture above is reposted from a certain expert’s problem statement.)
Little K is daydreaming again. In his fantasy, he found a very interesting sequence and a very interesting number .
Problem Description
For a sequence interval , we define its -th order subsegment sum as , where
$$sum_{k,l,r}=\begin{cases}\sum\limits_{i=l}^{r}a_i&,k=1\\\sum\limits_{i=l}^{r}\sum\limits_{j=i}^{r}sum_{k-1,i,j}&,k\geq 2\end{cases}$$He is now standing at position . Each time he expands one cell to the right, he can increase his rp on the IOI contest field, so he wants to expand as many cells as possible. However, every time he expands from to , he needs to correctly answer . Little K cannot be bothered to calculate it, so he leaves the task to you.
Input Format
Two lines. The first line contains , representing the length of and .
The second line contains positive integers, representing .
Output Format
One line. The -th number is . Since the answer is too large, you only need to output the value modulo .
3 1
1 2 3
1 3 6
3 2
1 2 3
1 6 20
3 10
1 2 3
1 30 420
Hint
Sample Explanation 2
$sum_{2,1,2}=sum_{1,1,1}+sum_{1,1,2}+sum_{1,2,2}=1+3+2=6$
$sum_{2,1,3}=sum_{1,1,1}+sum_{1,1,2}+sum_{1,1,3}+sum_{1,2,2}+sum_{1,2,3}+sum_{1,3,3}=1+3+6+2+5+3=20$
Constraints
| Test Point ID | Range of | Range of | Range of |
|---|---|---|---|
Translated by ChatGPT 5