#P6435. 「EZEC-1」数列
「EZEC-1」数列
Description
You are given a positive integer , and the sequence .
For each pair of adjacent terms, take times the left term plus times the right term, then add . This produces a new sequence with terms:
$1\times a+2\times b+c,2\times a+3\times b +c,\ldots,(n-1)\times a+n\times b+c$.
Repeat the above operation on this new sequence to obtain more sequences. In the end, the final sequence has only one term. Find the value of this term modulo .
Input Format
One line with five non-negative integers .
Output Format
One integer, the answer modulo .
1 1 1 1 1000000007
1
4 2 3 1 1000000007
381
23 19 17 0 1000000007
323147645
233 233 233 233 1000000000
770969703
Hint
[Sample Explanation]
Sample 2:
The sequences are:
1 2 3 4
9 14 19
61 86
381
[Constraints]
| Test Point ID | ||||
|---|---|---|---|---|
-
For of the testdata, is a prime.
-
For of the testdata, , , , and .
Translated by ChatGPT 5
京公网安备 11011102002149号