No.1528 Not 1
タグ : / 解いたユーザー数 212
作問者 :
PCTprobability
/ テスター :
tatyam
👑
hamamu
Problem Statement
Construct a sequence of positive integers $A_1,A_2,...,A_{\left\lceil \frac{N}{2} \right\rceil}$ of length $\displaystyle \left\lceil \frac{N}{2} \right\rceil$ that satisfies the following conditions. If no sequence satisfying the conditions exists, report that fact.
- $1 \le A_i \le N$
- If $i \neq j$, then $A_i \neq A_j$
- $\mathrm{gcd}(A_i,A_{i+1}) \neq 1\ (1 \le i \le \displaystyle \left\lceil \frac{N}{2} \right\rceil -1)$
Here, $\displaystyle \lceil x \rceil$ denotes the smallest integer greater than or equal to the real number $x$.
Input
$N$
- All inputs are integers.
- $1 \le N \le 2 \times 10^5$
Output
If no sequence of positive integers satisfying the conditions exists, print $-1$.
If a sequence of positive integers satisfying the conditions exists, print such a sequence separated by spaces, as follows.
If there are multiple solutions, you may print any of them.
$A_1\ A_2\ \dots\ A_{\left\lceil \frac{N}{2} \right\rceil}$
Sample
Sample 1
Input
11
Output
3 9 6 2 10 5
All elements are at most $11$ and distinct, and since $\mathrm{gcd}(3,9)=3,\mathrm{gcd}(9,6)=3,\mathrm{gcd}(6,2)=2,\mathrm{gcd}(2,10)=2,\mathrm{gcd}(10,5)=5$, the conditions are satisfied.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。