QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 256 MB 満点: 100 ハック可能 ✓

#6771. K-skip 排列

統計

对于一个 $n$ 的排列 $P = p_1, p_2, \dots, p_n$,令 $f(P, k)$ 为满足 $1 \le i < n$ 且 $p_i + k = p_{i+1}$ 的下标 $i$ 的个数。 给定两个整数 $n$ 和 $k$,你的任务是找到一个 $n$ 的排列 $P$,使得 $f(P, k)$ 最大化。 回想一下,在 $n$ 的排列中,从 $1$ 到 $n$ 的每个整数(包含 $1$ 和 $n$)恰好出现一次。

输入格式

每个测试文件中只有一个测试用例。 第一行也是唯一一行包含两个整数 $n$ 和 $k$ ($1 \le n, k \le 10^6$)。

输出格式

输出一行,包含 $n$ 个整数,表示一个使 $f(P, k)$ 最大化的 $n$ 的排列 $P$。如果有多个有效的答案,你可以输出其中任意一个。 请注意,不要在行末输出多余的空格,否则你的答案可能会被判定为错误!

样例

样例输入 1

3 1

样例输出 1

1 2 3

样例输入 2

7 3

样例输出 2

2 5 1 4 7 3 6

样例输入 3

3 7

样例输出 3

1 3 2

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.