#P16220. [ECUSTPC 2025] 浮点

    ID: 18235 远端评测题 1000ms 1024MiB 尝试: 0 已通过: 0 显示难度普及− 上传者: 标签>2025Special Judge位运算构造高校校赛

[ECUSTPC 2025] 浮点

Problem Description

Maddy encountered a machine. In front of the machine, she needs to report a long sequence of numbers so that she can obtain the Crystal Heart.
The machine first tells Maddy an integer nn. Specifically, the sequence must satisfy the following:

  1. The sequence consists of nn integers within [0,230)[0, 2^{30}), denoted as a1,a2,,ana_1, a_2, \dots, a_n.
  2. For all 1i<n1 \le i < n, it holds that ai<ai+1a_i < a_{i+1} and $a_i \text{ xor } a_{i+1} < a_i \text{ and } a_{i+1}$.

Please help Maddy find such a sequence, or tell Maddy that no solution exists.

Input Format

The first line contains an integer TT (1T1031 \le T \le 10^3), representing the number of testdata.
The only line of each testdata contains an integer nn (2n1062 \le n \le 10^6), representing the number given by the machine to Maddy.
It is guaranteed that n106\sum n \le 10^6 over all testdata.

Output Format

For each testdata, if such a sequence exists, output one line with nn integers representing a sequence that satisfies the machine’s requirements. If it does not exist, output a single integer 1-1 in one line.
If there are multiple valid answers, you may output any one of them.

4
2
3
4
5
9 15
4 5 6
9 10 12 15
8 9 10 11 12

Hint

Sample 1 Explanation

For the 1st sample, a1 xor a2=9 xor 15=6a_1 \text{ xor } a_2 = 9 \text{ xor } 15 = 6, and a1 and a2=9 and 15=9a_1 \text{ and } a_2 = 9 \text{ and } 15 = 9, so a1 xor a2<a1 and a2a_1 \text{ xor } a_2 < a_1 \text{ and } a_2. It is also easy to see that a1<a2a_1 < a_2.
For the 2nd sample,

  • a1 xor a2=4 xor 5=1a_1 \text{ xor } a_2 = 4 \text{ xor } 5 = 1, and a1 and a2=4 and 5=4a_1 \text{ and } a_2 = 4 \text{ and } 5 = 4, so a1 xor a2<a1 and a2a_1 \text{ xor } a_2 < a_1 \text{ and } a_2. It is also easy to see that a1<a2a_1 < a_2.
  • a2 xor a3=5 xor 6=3a_2 \text{ xor } a_3 = 5 \text{ xor } 6 = 3, and a2 and a3=5 and 6=4a_2 \text{ and } a_3 = 5 \text{ and } 6 = 4, so a2 xor a3<a2 and a3a_2 \text{ xor } a_3 < a_2 \text{ and } a_3. It is also easy to see that a2<a3a_2 < a_3.

Hint

For two integers aa and bb, a xor ba \text{ xor } b denotes the bitwise XOR, meaning a bit in the binary representation of the result is 1 if and only if in the binary representations of the original numbers, exactly one of them has a 1 at that bit.
For two integers aa and bb, a and ba \text{ and } b denotes the bitwise AND, meaning a bit in the binary representation of the result is 1 if and only if in the binary representations of the original numbers, both have a 1 at that bit.

Translated by ChatGPT 5