Professional Documents
Culture Documents
Problem Q. Avoid Squares Please: N P I P
Problem Q. Avoid Squares Please: N P I P
For any index i (1 ≤ i < N), Pi × Pi+1 is not a perfect square.
If there are multiple correct answers, you may print any of them.
Input Format
The first line of input contains a single integer T , denoting the number of test cases. The
description of T test cases follows.
The first line of each test case contains an integer N - the length of the required
permutation.
Output Format
For each test case, print N space-separated integers representing the valid permutation on a
single line.
If there are multiple correct answers, you may print any of them.
Constraints
1 ≤ T ≤ 500
2 ≤ N ≤ 500
Sample 1
Input Output
3
2 1
2
3 1 2
3
4 2 3 1
Test case 1: 2 × 1 = 2 is not a perfect square. Note that [1, 2] is also a valid answer for this case,
and will be accepted.
-
Pratica 01-Instic training Nov 08, 2022
Test case 2: 3 × 1 = 3 and 1 × 2 = 2 are not perfect squares.