P15676 [CodeChef] EARTSEQ
提高
题目描述

Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

For a set of positive integers $S$, let's define $\mathrm{gcd}(S)$ as the greatest integer which divides each element of $S$. If $\mathrm{gcd}(S) = 1$, the set $S$ is called coprime. For example, the set $\{7, 12, 15\}$ is coprime, but $\{6, 12, 15\}$ is not coprime, since every element of this set is divisible by $3$.

Your task is to find an integer sequence $A_{0}, A_{1}, \ldots, A_{N-1}$ such that:
for each valid $i$, $1 ≤ A_{i} ≤ 10^{9}$
$A_{0}, A_{1}, \ldots, A_{N-1}$ are pairwise distinct
for each valid $i$, the set $\{A_{i}, A_{(i+1)\%N}\}$ is not coprime ($\%$ denotes the modulo operator)
for each valid $i$, the set $\{A_{i}, A_{(i+1)\%N}, A_{(i+2)\%N}\}$ is coprime

It is possible that there is no solution. If there are multiple solutions, you may find any one.

------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $N$.

------ Output ------
For each test case:
If there is no solution, print a single line containing the integer $-1$.
Otherwise, print a single line containing $N$ space-separated integers $A_{0}, A_{1}, \ldots, A_{N-1}$.

------ Constraints ------
$1 ≤ T ≤ 1,000$
$3 ≤ N ≤ 50,000$
the sum of $N$ over all test cases does not exceed $10^{6}$

------ Subtasks ------
Subtask #1 (19 points): $3 ≤ N ≤ 3,333$

Subtask #2 (81 points): original constraints

----- Sample Input 1 ------
2
3
4
----- Sample Output 1 ------
6 10 15
374 595 1365 858
----- explanation 1 ------
Example case 1: Let's check the answer: $\mathrm{gcd}(6, 10) = 2$, $\mathrm{gcd}(10, 15) = 5$, $\mathrm{gcd}(15, 6) = 3$, $\mathrm{gcd}(6, 10, 15) = 1$. Every two cyclically consecutive numbers are not coprime, but every three cyclically consecutive numbers are coprime.

Example case 2:
- $\mathrm{gcd}(374, 595) = 17$, $\mathrm{gcd}(595, 1365) = 35$, $\mathrm{gcd}(1365, 868) = 39$, $\mathrm{gcd}(858, 374) = 22$
- $\mathrm{gcd}(374, 595, 1365) = 1$, $\mathrm{gcd}(595, 1365, 858) = 1$, $\mathrm{gcd}(1365, 858, 374) = 1$, $\mathrm{gcd}(858, 374, 595) = 1$

输入格式

见题面

输出格式

见题面

样例输入
2 3 4
样例输出
6 10 15 374 595 1365 858