GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Saturday, 20 August 2022

[Solution] Beautiful Array Codeforces Solution


B. Beautiful Array
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Stanley defines the beauty of an array a of length n, which contains non-negative integers, as follows:

∑i=1n⌊aik⌋,
which means that we divide each element by k, round it down, and sum up the resulting values.

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.

Input

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

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

The first line of each test case contains integers n, k, b, s (1≤n≤105, 1≤k≤109, 0≤b≤109, 0≤s≤1018).

It is guaranteed that the sum of n over all test cases does not exceed 105.

Output

For each test case print −1 if such array a does not exist. Otherwise print n non-negative integers a1,a2,…,an (0≤ai≤1018) — the answer.

No comments:

Post a Comment