QOJ.ac

QOJ

حد الوقت: 3.0 s حد الذاكرة: 256 MB مجموع النقاط: 100 قابلة للهجوم ✓

#9073. 数组修改

الإحصائيات

给定一个包含 $n$ 个数字的数组 $A$ 以及两个整数 $L, m$。你需要输出在执行以下操作 $m$ 次后的最终数组:

$$A[i] = \left( \sum_{j=i}^{\min(i+L-1, n)} A[j] \right) \bmod P, \quad \text{对于 } i = 1, 2, \dots, n$$

其中 $P = 998, 244, 353$ 是一个固定常数。

输入格式

输入文件的第一行包含一个整数 $T$ ($1 \le T \le 20$),表示测试用例的数量。 接下来有 $2 \times T$ 行,每两行表示一个测试用例。 每个测试用例的第一行包含三个整数:$n, L, m$ ($1 \le n \le 100,000, 1 \le L \le n, 1 \le m \le 10^9$)。 每个测试用例的第二行包含 $n$ 个整数,其中第 $i$ 个数表示 $A[i]$ ($0 \le A[i] < P$, 对于 $i = 1, 2, \dots, n$)。 保证所有测试用例中 $n$ 的总和不超过 $200,000$。

输出格式

你需要输出 $T$ 行。 对于每个测试用例,首先打印 Case d:($d$ 表示测试用例的编号),然后输出 $n$ 个整数,表示最终的 $A[i]$,整数之间用一个空格隔开。

样例

输入格式 1

2
3 2 2
1 2 3
4 1 3
1 2 3 4

输出格式 1

Case 1: 8 8 3
Case 2: 1 2 3 4

说明

样例 1:

初始状态:$A = [1, 2, 3]$

第一次操作: $A[1] = (A[1] + A[2]) \bmod P = (1 + 2) \bmod P = 3$ $A[2] = (A[2] + A[3]) \bmod P = (2 + 3) \bmod P = 5$ $A[3] = (A[3]) \bmod P = 3$ 此时 $A = [3, 5, 3]$

第二次操作: $A[1] = (A[1] + A[2]) \bmod P = (3 + 5) \bmod P = 8$ $A[2] = (A[2] + A[3]) \bmod P = (5 + 3) \bmod P = 8$ $A[3] = (A[3]) \bmod P = 3$ 此时 $A = [8, 8, 3]$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.