CF1715B.Beautiful Array

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Stanley defines the beauty of an array aa of length nn, 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 kk, round it down, and sum up the resulting values.

Stanley told Sam the integer kk and asked him to find an array aa of nn non-negative integers, such that the beauty is equal to bb and the sum of elements is equal to ss. Help Sam — find any of the arrays satisfying the conditions above.

斯坦利将一个长度为 nn、包含非负整数的数组 aa 的“美观度”定义如下:

∑i=1n⌊aik⌋,\sum\limits_{i = 1}^{n} \left \lfloor \frac{a_{i}}{k} \right \rfloor,

即:将每个元素除以 kk 后向下取整,再将所有结果求和。

斯坦利告诉了萨姆整数 kk,并请他找出一个由 nn 个非负整数组成的数组 aa,使得该数组的美观度恰好为 bb,且所有元素之和恰好为 ss。请帮助萨姆——找出任意一个满足上述条件的数组。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤10001 \le t \le 1000). Description of the test cases follows.

The first line of each test case contains integers nn, kk, bb, ss (1≤n≤1051 \leq n \leq 10^{5}, 1≤k≤1091 \leq k \leq 10^{9}, 0≤b≤1090 \leq b \leq 10^{9}, 0≤s≤10180 \leq s \leq 10^{18}).

It is guaranteed that the sum of nn over all test cases does not exceed 10510^5.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤10001 \le t \le 1000)。随后是各测试用例的描述。

每个测试用例的第一行包含整数 nn、kk、bb、ss(1≤n≤1051 \leq n \leq 10^{5},1≤k≤1091 \leq k \leq 10^{9},0≤b≤1090 \leq b \leq 10^{9},0≤s≤10180 \leq s \leq 10^{18})。

保证所有测试用例中 nn 的总和不超过 10510^5。

输出格式

For each test case print −1-1 if such array aa does not exist. Otherwise print nn non-negative integers a1,a2,…,ana_1, a_2, \ldots, a_n (0≤ai≤10180 \leq a_{i} \leq 10^{18}) — the answer.

如果不存在满足条件的数组 aa,则对每个测试用例输出 −1-1;否则输出 nn 个非负整数 a1,a2,…,ana_1, a_2, \ldots, a_n(其中 0≤ai≤10180 \leq a_{i} \leq 10^{18})——即答案。

输入输出样例

  • 输入#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]a = [0, 0, 19]. The sum of elements in it is equal to 19, the beauty of it is equal to (⌊06⌋+⌊06⌋+⌊196⌋)=(0+0+3)=3\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]a = [0, 3, 3, 3, 29]. The sum of elements in it is equal to 3838, the beauty of it is equal to (0+0+0+0+7)=7(0 + 0 + 0 + 0 + 7) = 7.

在示例的第一、第二、第五和第六个测试用例中,可以证明这样的数组不存在。

在示例的第三个测试用例中,a=[0,0,19]a = [0, 0, 19]。其元素之和为 1919,其美观度为 (⌊06⌋+⌊06⌋+⌊196⌋)=(0+0+3)=3\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。

在示例的第四个测试用例中,a=[0,3,3,3,29]a = [0, 3, 3, 3, 29]。其元素之和为 3838,其美观度为 (0+0+0+0+7)=7(0 + 0 + 0 + 0 + 7) = 7。

输入解题思路,AI测评打分。不知道怎么写?

首页