[Solution] Avoid Squares Please CodeChef Solution
Problem
You are given an integer .
Print a permutation of such that the following condition holds:
- For any index , is not a perfect square.
If there are multiple correct answers, you may print any of them.
Note: A permutation of is a rearrangement of those numbers.
Input Format
- The first line of input contains a single integer , denoting the number of test cases. The description of test cases follows.
- The first line of each test case contains an integer - the length of the required permutation.
Output Format
For each test case, print space-separated integers representing the valid permutation on a single line.
If there are multiple correct answers, you may print any of them.
Explanation:
Test case : is not a perfect square. Note that is also a valid answer for this case, and will be accepted.
Test case : and are not perfect squares.
Test case : are all not perfect squares
No comments:
Post a Comment