[ICPC2020 Nanjing R] K Co-prime Permutation
题意翻译
### 题目描述
给定两个整数 $n$ 和 $k$,构造一个 $1 \sim n$ 的排列 $p_1,p_2,\cdots,p_n$,使得存在 $k$ 个整数 $i$ 满足 $1 \le i \le n$ 且 $\text{gcd}(p_i,i)=1$。
$\text{gcd}(x,y)$ 表示 $x$ 和 $y$ 的最大公约数。
### 输入格式
只有一组测试数据。
第一行输入两个整数 $n$ 和 $k$ $(1 \le n \le 10^6, 0 \le k \le n)$。
### 输出格式
输出一行 $n$ 个整数 $p_1, p_2, \cdots, p_n$,用空格分隔,表示一个满足给定的约束的排列。如果没有存在的排列则输出 ``-1``。如果有多个有效的答案,输出任意一个均可。
请不要在行末输出多余的空格,否则你的答案可能会被认为是错误的。
### 样例 #1
#### 样例输入 #1
```
5 3
```
#### 样例输出 #1
```
1 4 5 2 3
```
### 样例 #2
#### 样例输入 #2
```
1 0
```
#### 样例输出 #2
```
-1
```
题目描述
Kotori is very good at math (really?) and she loves playing with permutations and primes.
One day, she thinks of a special kind of permutation named $\textit{k co-prime permutation}$. A permutation $p_1,p_2,\cdots,p_n$ of $n$ is called a $k$ co-prime permutation of $n$ if there exists exactly $k$ integers $i$ such that $1 \le i \le n$ and $\text{gcd}(p_i,i)=1$, where $\text{gcd}(x,y)$ indicates the greatest common divisor of $x$ and $y$.
Given $n$ and $k$, please help Kotori construct a $k$ co-prime permutation of $n$ or just report that there is no such permutation.
Recall that a permutation of $n$ is a sequence of length $n$ containing all integers from $1$ to $n$.
输入输出格式
输入格式
There is only one test case in each test file.
The first and only line contains two integers $n$ and $k$ ($1 \le n \le 10^6$, $0 \le k \le n$).
输出格式
Output one line containing $n$ integers $p_1, p_2, \cdots, p_n$ separated by one space, indicating the permutation satisfying the given constraints. If no such permutation exists output ``-1`` (without quotes) instead. If there are multiple valid answers you can print any of them.
Please, DO NOT output extra spaces at the end of each line, otherwise your answer may be considered incorrect!
输入输出样例
输入样例 #1
5 3
输出样例 #1
1 4 5 2 3
输入样例 #2
1 0
输出样例 #2
-1