#P17447. 简单构造题 / A Simple Construction Problem
简单构造题 / A Simple Construction Problem
Problem Description
A "Hongzhuan sequence" of length is a sequence that satisfies the following properties:
- Each integer from to appears in the sequence exactly once.
- The sum of every pair of adjacent elements is not a perfect square.
Given an integer , construct a "Hongzhuan sequence" of length .
Input Format
The first line contains an integer (), meaning the number of test cases.
For each test case, there is only one line containing one integer (), meaning the length of the "Hongzhuan sequence" to construct.
It is guaranteed that the sum of all does not exceed . It can be proven that under the given conditions, a solution always exists.
Output Format
Output lines. Each line should be the constructed sequence. If there are multiple solutions, output any one.
5
1
2
3
4
5
1
1 2
1 2 3
1 2 3 4
1 4 2 3 5
Hint
For , if the output is 1 2 3 4 5, it is wrong, because is a perfect square.
Translated by ChatGPT 5