#P3169. [CQOI2015] 多项式

    ID: 2218 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>数学递推2015重庆各省省选矩阵加速,矩阵优化

[CQOI2015] 多项式

Description

After learning the binomial theorem, the math teacher gave a problem: given integers n,tn, t and aka_k (0kn0\le k\le n), find the expressions for bkb_k (0kn0\le k\le n) such that:

k=0nakxk=k=0nbk(xt)k\sum_{k=0}^n a_kx^k=\sum_{k=0}^nb_k(x-t)^k

The students quickly worked out the answer. Seeing everyone finish so fast, the teacher assigned an even more brutal task: compute the specific value of some bkb_k. Then the teacher wrote the values of n,tn, t on the blackboard. Since there were too many aka_k to write out, the teacher only provided a recurrence for aka_k and asked the students to compute it themselves:

$$a_k= \begin{cases} (1234\cdot a_{k-1}+5678)\bmod 3389 & k\gt 0 \\ 1 & k=0 \\ \end{cases}$$

As someone learning competitive programming, you feel this homework is not suitable for manual calculation, so you start coding.

Input Format

The input consists of three lines. The first line contains a positive integer nn. The second line contains a non-negative integer tt. The third line contains a non-negative integer mm.

Output Format

Output one line containing the value of bmb_m.

3
2
2
10536

Hint

Constraints:

  • For 20% of the testdata, t=0t=0.
  • For another 30% of the testdata, n105n\le 10^5.
  • For 100% of the testdata, 0<n1030000\lt n\le 10^{3000}, 0t1040\le t\le 10^4, 0nm50\le n-m\le 5.

Translated by ChatGPT 5