#P8979. 「DTOI-4」白的 Fibonacci
「DTOI-4」白的 Fibonacci
Problem Description
Define as follows:
$$F(k,n) = \left \{ \begin{aligned} &st_0\ && k = 1\ \land\ n = 0 \\ &st_1\ && k = 1\ \land\ n = 1 \\ &0\ && k > 1 \ \land \ n < 0 \\ &a \times F(k, n - 1) + b \times F(k, n - 2)\ && k = 1 \ \land\ n > 1 \\ &t_k \times F(k, n - 1) + s^n \times F(k - 1, n)\ && \text{otherwise} \end{aligned} \right.$$Given the coefficients in the recurrence of and , compute the value of .
Input Format
The first line contains two integers .
The second line contains five integers .
The third line contains integers .
Output Format
Output one integer on a single line, which is the answer.
10 25
-5 -73 -95 64 15
-80 -31 -58 15 95 -1 14 -30 31
998096342
Hint
| Special Property | Score | |||
|---|---|---|---|---|
| None | ||||
| None |
For of the testdata, , , and $-998244352 \leq st_0, st_1, a, b, s, t_i \leq 998244352$.
Translated by ChatGPT 5