CF BUDDY
← Problems·

1715B · Beautiful Array

1000 · constructive algorithms, greedy, math

Problem: Stanley defines the beauty of an array aa of length nn, which contains non-negative integers, as follows: i=1naik,\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.

Input Format: Each test contains multiple test cases. The first line contains the number of test cases tt (1t10001 \le t \le 1000). Description of the test cases follows.

The first line of each test case contains integers nn, kk, bb, ss (1n1051 \leq n \leq 10^{5}, 1k1091 \leq k \leq 10^{9}, 0b1090 \leq b \leq 10^{9}, 0s10180 \leq s \leq 10^{18}).

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

Output Format: 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 (0ai10180 \leq a_{i} \leq 10^{18}) — the answer.

Note: 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.

Sample Cases

Case 1

Input

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

Output

-1
-1
0 0 19
0 3 3 3 29
-1
-1
0
0 0 0 1000000000000000000

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback