QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 256 MB Puntuación total: 100

#6428. K 互质排列

Estadísticas

Kotori 非常擅长数学(真的吗?),她喜欢研究排列和素数。

有一天,她想出了一种特殊的排列,称为 $k$ 互质排列。对于 $n$ 的一个排列 $p_1, p_2, \dots, p_n$,如果恰好存在 $k$ 个整数 $i$ 满足 $1 \le i \le n$ 且 $\gcd(p_i, i) = 1$,其中 $\gcd(x, y)$ 表示 $x$ 和 $y$ 的最大公约数,则称该排列为 $n$ 的 $k$ 互质排列。

给定 $n$ 和 $k$,请帮助 Kotori 构造一个 $n$ 的 $k$ 互质排列,或者报告不存在这样的排列。

回想一下,$n$ 的排列是一个长度为 $n$ 的序列,包含从 $1$ 到 $n$ 的所有整数。

输入格式

每个测试文件中仅包含一组测试数据。 第一行包含两个整数 $n$ 和 $k$ ($1 \le n \le 10^6, 0 \le k \le n$)。

输出格式

输出一行,包含 $n$ 个整数 $p_1, p_2, \dots, p_n$,用空格分隔,表示满足给定约束的排列。如果不存在这样的排列,则输出 “-1”(不含引号)。如果存在多个有效答案,你可以输出其中任意一个。

请注意,不要在每行末尾输出多余的空格,否则你的答案可能会被判为错误!

样例

输入 1

5 3

输出 1

1 4 5 2 3

输入 2

1 0

输出 2

-1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.