Exactly N plus 1 Values solution codechef

Exactly N plus 1 Values solution codechef

You are given a positive integer NN. You have to print exactly N+1N+1 positive integers satisfying the following conditions:

  • Exactly one value should appear twice, all the remaining values should appear only once.
  • Sum of all these values should be equal to 2N2N.

You have to print the values in non-decreasing order. If there are multiple solutions, you can print any of them.

Input Format

Exactly N plus 1 Values solution codechef

  • The first line of the input contains a single integer TT denoting the number of test cases. The description of TT test cases follows.
  • The first and only line of each test case contains a single integer NN.

Output Format

Exactly N plus 1 Values solution codechef

For each test case, print a single line containing N+1N+1 positive integers in non-decreasing order that satisfy the given conditions. If there are multiple solutions, you may print any of them.

Constraints

Exactly N plus 1 Values solution codechef

  • 1T601≤T≤60
  • 1N601≤N≤60

Subtasks

  • Subtask 1 (100 points): Original constraints

Sample Input 1

Exactly N plus 1 Values solution codechef

2
3
4

Sample Output 1 

1 2 2 3
1 2 3 3 7

Explanation

Exactly N plus 1 Values solution codechef

Test Case 11: 22 is repeated twice and the remaining elements occurred only once and the sum of all the elements is equal to 88, which is 2323.

Test Case 22: 33 is repeated twice and the remaining elements occurred only once and the sum of all the elements is equal to 1616, which is 2424.

Leave a Comment