题库练习 Modular Sequence
← 上一题 下一题 →

A11333 | Modular Sequence

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You are given two integers $x$ and $y$ . A sequence $a$ of length $n$ is called modular if $a_1=x$ , and for all $1 < i \le n$ the value of $a_{i}$ is either $a_{i-1} + y$ or $a_{i-1} \bmod y$ . Here $x \bmod y$ denotes the remainder from dividing $x$ by $y$ .

Determine if there exists a modular sequence of length $n$ with the sum of its elements equal to $S$ , and if it exists, find any such sequence.

输入格式

Each test contains multiple test cases. The first line contains the number of test cases $t$ ( $1 \le t \le 2 \cdot 10^4$ ). The description of the test cases follows.

The first and only line of each test case contains four integers $n$ , $x$ , $y$ , and $s$ ( $1 \le n \le 2 \cdot 10^5$ , $0 \le x \le 2 \cdot 10^5$ , $1 \le y \le 2 \cdot 10^5$ , $0 \le s \le 2 \cdot 10^5$ ) — the length of the sequence, the parameters $x$ and $y$ , and the required sum of the sequence elements.

The sum of $n$ over all test cases does not exceed $2 \cdot 10^5$ , and also the sum of $s$ over all test cases does not exceed $2 \cdot 10^5$ .

输出格式

For each test case, if the desired sequence exists, output "Yes" on the first line (without quotes). Then, on the second line, output $n$ integers $a_1, a_2, \ldots, a_n$ separated by a space — the elements of the sequence $a$ . If there are multiple suitable sequences, output any of them.

If the sequence does not exist, output "No" on a single line.

You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.

输入输出样例

输入 #1
3
5 8 3 28
3 5 3 6
9 1 5 79
输出 #1
YES
8 11 2 2 5 
NO
NO
C++ 编辑器
输入
输出