#P7342. 『MdOI R4』Destiny
『MdOI R4』Destiny
Description
Note that in this problem, indices start from .
For a sequence of length , its weight is defined as:
- When , .
- When , it is the sum of the weights of all its subsegments, that is, $v(a_0,a_1,\ldots,a_{n-1})=\sum\limits_{i=0}^{n-2}\sum\limits_{j=0}^{n-i-1}v(a_j,a_{j+1},\ldots,a_{j+i})$.
Given a sequence, compute its weight, and output the answer modulo .
The sequence is generated as follows: input a sequence , then .
Input Format
The first line contains , representing the length of sequence and the length of sequence .
The second line contains , with the meaning described above.
Output Format
Output one integer per line, representing the weight of sequence modulo .
4 3
3 4 6
104
10 10
2 5 3 8 4 5 2 19 3 6
219856
Hint
[Sample Explanation #1]
Generate the sequence , then:
- $v(3,4,6,3)=v(3)+v(4)+v(6)+v(3)+v(3,4)+v(4,6)+v(6,3)+v(3,4,6)+v(4,6,3)=104$
[Constraints]
This problem does not use bundled tests.
There are test points in total, and each test point is worth points.
| Test Point ID | ||
|---|---|---|
| No special restrictions | ||
| No special restrictions | ||
| No special restrictions |
For of the testdata: ,,。
Thanks to for contributing to this problem.
Translated by ChatGPT 5
京公网安备 11011102002149号