#P9632. [ICPC2020 Nanjing R] K Co-prime Permutation

    ID: 8925 Type: RemoteJudge 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 2 Uploaded By: Tags>2020Special JudgeO2优化XCPC

[ICPC2020 Nanjing R] K Co-prime Permutation

题目描述

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 k co-prime permutation\textit{k co-prime permutation}. A permutation p1,p2,,pnp_1,p_2,\cdots,p_n of nn is called a kk co-prime permutation of nn if there exists exactly kk integers ii such that 1in1 \le i \le n and gcd(pi,i)=1\text{gcd}(p_i,i)=1, where gcd(x,y)\text{gcd}(x,y) indicates the greatest common divisor of xx and yy.

Given nn and kk, please help Kotori construct a kk co-prime permutation of nn or just report that there is no such permutation.

Recall that a permutation of nn is a sequence of length nn containing all integers from 11 to nn.

输入格式

There is only one test case in each test file.

The first and only line contains two integers nn and kk (1n1061 \le n \le 10^6, 0kn0 \le k \le n).

输出格式

Output one line containing nn integers p1,p2,,pnp_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!

题目大意

题目描述

给定两个整数 nnkk,构造一个 1n1 \sim n 的排列 p1,p2,,pnp_1,p_2,\cdots,p_n,使得存在 kk 个整数 ii 满足 1in1 \le i \le ngcd(pi,i)=1\text{gcd}(p_i,i)=1

gcd(x,y)\text{gcd}(x,y) 表示 xxyy 的最大公约数。

输入格式

只有一组测试数据。

第一行输入两个整数 nnkk (1n106,0kn)(1 \le n \le 10^6, 0 \le k \le n)

输出格式

输出一行 nn 个整数 p1,p2,,pnp_1, p_2, \cdots, p_n,用空格分隔,表示一个满足给定的约束的排列。如果没有存在的排列则输出 -1。如果有多个有效的答案,输出任意一个均可。

请不要在行末输出多余的空格,否则你的答案可能会被认为是错误的。

样例 #1

样例输入 #1

5 3

样例输出 #1

1 4 5 2 3

样例 #2

样例输入 #2

1 0

样例输出 #2

-1
5 3
1 4 5 2 3
1 0
-1