#K36857. Odd XOR Array Construction
Odd XOR Array Construction
Odd XOR Array Construction
In this problem, you are given an integer N and you must construct an array A of length N according to the following rules:
- If N is 0, output an empty array (i.e. print an empty line).
- If N is odd, then A should consist of the first N positive integers; that is, A[i] = i+1 for 0 ≤ i < N.
- If N is even, then A should be constructed with a repeating pattern: A[i] = 1 + (i mod 2) for 0 ≤ i < N. For example, if N = 4, then A = [1, 2, 1, 2].
You will be given T test cases. For each test case, output the corresponding array. Each array must be printed on a new line with its elements separated by a single space.
Note: Although the problem title mentions 'Odd XOR Array', the construction follows the above simple rule and not the actual XOR of subarrays.
inputFormat
The input is read from standard input (stdin). The first line contains an integer T, the number of test cases. Each of the following T lines contains a single non‐negative integer N.
outputFormat
For each test case, print the constructed array on a separate line. The numbers within each array should be printed in order and separated by a single space. If N is 0, an empty line should be printed.## sample
3
1
2
3
1
1 2
1 2 3
</p>