QOJ.ac

QOJ

Time Limit: 1.5 s Memory Limit: 512 MB Total points: 100

#146. 常系数齐次线性递推

Statistics

已知一个整数序列 $a_0,a_1,\cdots$ 满足以下线性递推关系:

$$\forall i \geq n, a_i \equiv \sum_{k=1}^n c_ka_{i-k} \pmod {998\,244\,353}$$

给定 $a_0,a_1,\cdots,a_{n-1}$,$c_1,c_1,\cdots,c_{n}$ 与 $k$,你想要计算 $a_k$ 取模 $998\,244\,353$ 的值。

输入格式

输入的第一行包含两个整数 $n,k$。

接下来一行,包含 $n$ 个整数 $a_0, a_1, \cdots, a_{n-1}$。

接下来一行,包含 $n$ 个整数 $c_1, c_1, \cdots, c_{n}$。

输出格式

输出一行一个整数,表示答案。

样例数据

样例 1 输入

3 10
2 5 3
1 4 6

样例 1 输出

58953

样例 2 输入

5 75789123
4 6 1 3 8
2 5 0 0 9

样例 2 输出

71403842

样例 3 输入

6 1999999
2 3 4 5 6 7
0 0 0 0 0 0

样例 3 输出

0

子任务

对于所有数据,$1 \leq n \leq 10^5$,$0 \leq k \leq 10^9$,$0 \leq a_i,c_i < 998\,244\,353$。

子任务编号 $n \leq $ 分值
$1$ $100$ $5$
$2$ $1\,000$ $20$
$3$ $5\,000$ $15$
$4$ $20\,000$ $5$
$5$ $30\,000$ $15$
$6$ $40\,000$ $5$
$7$ $60\,000$ $10$
$8$ $80\,000$ $10$
$9$ $10^5$ $15$
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.