A15349 | Beautiful Array
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Stanley defines the beauty of an array $a$ of length $n$ , which contains non-negative integers, as follows: $$$$\sum\limits_{i = 1}^{n} \left \lfloor \frac{a_{i}}{k} \right \rfloor, $$ which means that we divide each element by $k$ , round it down, and sum up the resulting values.</p><p>Stanley told Sam the integer $k$ and asked him to find an array $a$ of $n$ non-negative integers, such that the beauty is equal to $b$ and the sum of elements is equal to $s$$$. Help Sam — find any of the arrays satisfying the conditions above.
输入格式
Each test contains multiple test cases. The first line contains the number of test cases $t$ ( $1 \le t \le 1000$ ). Description of the test cases follows.
The first line of each test case contains integers $n$ , $k$ , $b$ , $s$ ( $1 \leq n \leq 10^{5}$ , $1 \leq k \leq 10^{9}$ , $0 \leq b \leq 10^{9}$ , $0 \leq s \leq 10^{18}$ ).
It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$ .
The first line of each test case contains integers $n$ , $k$ , $b$ , $s$ ( $1 \leq n \leq 10^{5}$ , $1 \leq k \leq 10^{9}$ , $0 \leq b \leq 10^{9}$ , $0 \leq s \leq 10^{18}$ ).
It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$ .
输出格式
For each test case print $-1$ if such array $a$ does not exist. Otherwise print $n$ non-negative integers $a_1, a_2, \ldots, a_n$ ( $0 \leq a_{i} \leq 10^{18}$ ) — the answer.
输入输出样例
输入 #1
8 1 6 3 100 3 6 3 12 3 6 3 19 5 4 7 38 5 4 7 80 99978 1000000000 100000000 1000000000000000000 1 1 0 0 4 1000000000 1000000000 1000000000000000000
输出 #1
-1 -1 0 0 19 0 3 3 3 29 -1 -1 0 0 0 0 1000000000000000000
In the first, the second, the fifth and the sixth test cases of the example it is possible to show that such array does not exist.
In the third testcase of the example $a = [0, 0, 19]$ . The sum of elements in it is equal to 19, the beauty of it is equal to $\left ( \left \lfloor \frac{0}{6} \right \rfloor + \left \lfloor \frac{0}{6} \right \rfloor + \left \lfloor \frac{19}{6} \right \rfloor \right ) = (0 + 0 + 3) = 3$ .
In the fourth testcase of the example $a = [0, 3, 3, 3, 29]$ . The sum of elements in it is equal to $38$ , the beauty of it is equal to $(0 + 0 + 0 + 0 + 7) = 7$ .
In the third testcase of the example $a = [0, 0, 19]$ . The sum of elements in it is equal to 19, the beauty of it is equal to $\left ( \left \lfloor \frac{0}{6} \right \rfloor + \left \lfloor \frac{0}{6} \right \rfloor + \left \lfloor \frac{19}{6} \right \rfloor \right ) = (0 + 0 + 3) = 3$ .
In the fourth testcase of the example $a = [0, 3, 3, 3, 29]$ . The sum of elements in it is equal to $38$ , the beauty of it is equal to $(0 + 0 + 0 + 0 + 7) = 7$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted