6965.Permutation Prime Sums

Time Limit: 1s Memory Limit: 512MB

Given $n$ , create two permutations $a$ and $b$ of size $n$ such that $a_i+b_i$ is prime for $i=1,2,\dots,n$ .

Input Format(From the terminal/stdin)

The only line has an integer $n$ .

  • $1 \le n \le 10^5$

Output Format(To the terminal/stdout)

Print two permutations. You can print any valid solution. If there are no solutions, print IMPOSSIBLE .

Sample Input

Copy
5
 \n

Sample Output special judge

Copy
2 1 3 5 4
5 1 4 2 3
 · · · · \n
 · · · · \n

The sums are $2+5=7$ , $1+1=2$ , $3+4=7$ , $5+2=7$ and $4+3=7$ which all are primes.

Source: CSES, Construction Problems, 3423

Submit

请先 登录

© 2025 FAQs