又一个构造题AI (CI翻译)
You are given three integers $n$, $k$, and $m$.
给定三个整数 $n$、$k$ 和 $m$。AI (CI翻译)
We call an array $a$ of length $n$, consisting of positive integers, good if the minimum length of a non-empty subarray$^{\text{∗}}$ of $a$ whose sum is divisible by $m$ equals $k$.
如果一个由正整数组成、长度为 $n$ 的数组 $a$ 中,元素和能被 $m$ 整除的非空子数组$^{\text{∗}}$的最小长度恰好为 $k$,则称 $a$ 是 good 的。AI (CI翻译)
Formally, an array $a$ is good if the following conditions hold:
形式化地说,数组 $a$ 是 good 的,当且仅当满足以下条件:AI (CI翻译)
- there exist integers
$l$and$r$such that$1 \le l \le r \le n$,$r - l + 1 = k$, and$\sum\limits_{i = l}^{r} a_i$is divisible by$m$; - there do not exist integers
$l$and$r$such that$1 \le l \le r \le n$,$r - l + 1 \lt k$, and$\sum\limits_{i = l}^{r} a_i$is divisible by$m$.
- 存在整数
$l$和$r$,使得$1 \le l \le r \le n$、$r - l + 1 = k$,且$\sum\limits_{i = l}^{r} a_i$能被$m$整除; - 不存在整数
$l$和$r$,使得$1 \le l \le r \le n$、$r - l + 1 \lt k$,且$\sum\limits_{i = l}^{r} a_i$能被$m$整除。
Find any good array $a$, or determine that no such array exists.
请构造任意一个 good 数组 $a$,或者判断不存在这样的数组。AI (CI翻译)
$^{\text{∗}}$An array $a$ is a subarray of an array $b$ if $a$ can be obtained from $b$ by the deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.
$^{\text{∗}}$如果数组 $a$ 可以通过删除数组 $b$ 开头的若干个(可以为零个或全部)元素,以及末尾的若干个(可以为零个或全部)元素得到,则称 $a$ 是数组 $b$ 的子数组。AI (CI翻译)
Input
输入格式
AI (CI翻译)Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.
每个输入包含多组测试用例。第一行包含测试用例数量 $t$($1 \le t \le 10^4$)。接下来是各测试用例的描述。AI (CI翻译)
The only line of each test case contains three integers $n$, $k$, and $m$ ($1 \le k \le n \le 2 \cdot 10^5$, $1 \le m \le 10^9$).
每个测试用例仅一行,包含三个整数 $n$、$k$ 和 $m$($1 \le k \le n \le 2 \cdot 10^5$,$1 \le m \le 10^9$)。AI (CI翻译)
It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.
保证所有测试用例的 $n$ 之和不超过 $2 \cdot 10^5$。AI (CI翻译)
Output
输出格式
AI (CI翻译)For each test case, if an answer exists, output "YES" on the first line. On the second line, output $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{18}$) — the array $a$ satisfying the conditions of the problem. If there are multiple valid solutions, output any of them.
对于每个测试用例,如果存在答案,在第一行输出 "YES"。在第二行输出 $n$ 个整数 $a_1, a_2, \ldots, a_n$($1 \le a_i \le 10^{18}$),表示满足题目条件的数组 $a$。如果存在多个合法答案,输出任意一个。AI (CI翻译)
Otherwise, output a single line containing "NO".
否则,输出仅包含 "NO" 的一行。AI (CI翻译)
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
答案中的大小写不限。例如,字符串 "yEs"、"yes"、"Yes" 和 "YES" 都会被识别为肯定回答。AI (CI翻译)
Note
说明
AI (CI翻译)In the first example, one possible solution is $a = [1]$. The only non-empty subarray has length $k = 1$, and its sum is divisible by $m = 1$.
在第一个样例中,一种可能的解是 $a = [1]$。唯一的非空子数组长度为 $k = 1$,且其元素和能被 $m = 1$ 整除。AI (CI翻译)
In the second example, one possible solution is $a = [9, 17, 14, 23, 11]$. The sum of the subarray $[9, 17, 14]$ is $9 + 17 + 14 = 40$, which is divisible by $m = 5$. It can be shown that no non-empty subarray with fewer than $k = 3$ elements has a sum divisible by $5$, so this solution is valid.
在第二个样例中,一种可能的解是 $a = [9, 17, 14, 23, 11]$。子数组 $[9, 17, 14]$ 的元素和为 $9 + 17 + 14 = 40$,能被 $m = 5$ 整除。可以证明,不存在长度小于 $k = 3$ 且元素和能被 $5$ 整除的非空子数组,因此该解合法。AI (CI翻译)
In the fourth example, it can be shown that no good array $a$ exists.
在第四个样例中,可以证明不存在 good 数组 $a$。AI (CI翻译)
样例
4
1 1 1
5 3 5
2 2 1000000000
6 4 3
YES
1
YES
9 17 14 23 11
YES
500000000 500000000
NO
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。