CodeChef Solution

Array Sum CodeChef Solution

We Are Discuss About CODECHEF SOLUTION

Array Sum CodeChef Solution

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW
JoinScishowEngineerTelegram

Problem

You are given an even integer  and an integer .
Generate an array  of size  such that:

  • 1≤��≤105 for all 1≤�≤�;
  • The number of odd elements in the array is same as the number of even elements.
  • The sum of all elements of the array is .

If multiple such arrays exist, print any. If no such array exists, print −1 instead.

Input Format

  • The first line of input will contain a single integer , denoting the number of test cases.
  • Each test case consists of two space-separated integers  and  — the size of the array and the required sum.

Output Format

For each test case, output on a new line,  space-separated integers, denoting the array  satisfying the given conditions.

If multiple such arrays exist, print any. If no such array exists, print −1 instead.

Constraints

  • 1≤�≤1000
  • 2≤�≤105 is even
  • 1≤�≤109
  • The sum of  over all test cases won’t exceed 106.

Sample 1:

Input

Output

3
2 5
4 1
4 20
4 1
-1
3 4 5 8

Explanation:

Test case 1: Consider the array �=[4,1]. It contains 1 even as well as 1 odd element. Also, the sum of elements of the array is 4+1=5.

Test case 2: It can be proven that there exists no array which satisfies the given conditions.

Test case 3: Consider the array �=[3,4,5,8]. It contains 2 even as well as 2 odd elements. Also, the sum of elements of the array is 3+4+5+8=20.

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW
JoinScishowEngineerTelegram


6 digit code appear after 69 seconds.
 

Wait for Solution



Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE