CF49C.Disposition

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasya bought the collected works of a well-known Berland poet Petya in n volumes. The volumes are numbered from 1 to n. He thinks that it does not do to arrange the book simply according to their order. Vasya wants to minimize the number of the disposition’s divisors — the positive integers i such that for at least one j (1 ≤ j ≤ n) is true both: j mod i = 0 and at the same time p(j) mod i = 0, where p(j) is the number of the tome that stands on the j-th place and mod is the operation of taking the division remainder. Naturally, one volume can occupy exactly one place and in one place can stand exactly one volume.

Help Vasya — find the volume disposition with the minimum number of divisors.

瓦西娅买了著名伯兰德诗人佩佳的文集,共 $ n $ 卷。各卷编号为 $ 1 $ 到 $ n $。他认为简单地按编号顺序排列这些书是不妥的。瓦西娅希望最小化该排列的“约数个数”——即满足如下条件的正整数 $ i $ 的个数:存在某个 $ j (( 1 \leq j \leq n $),使得同时成立

j mod i=0且p(j) mod i=0,j \bmod i = 0 \quad \text{且} \quad p(j) \bmod i = 0,

其中 $ p(j) $ 表示排在第 $ j $ 个位置上的卷册编号,“$ \bmod $”表示取模运算(即除法余数)。显然,每卷书恰好占据一个位置,每个位置上恰好摆放一卷书。

请帮助瓦西娅——找出一个使约数个数最小的卷册排列方案。

输入格式

The first line contains number n (1 ≤ n ≤ 100000) which represents the number of volumes and free places.

第一行包含一个数字 nn(1≤n≤1000001 \leq n \leq 100000),表示书卷数量和空位数量。

输出格式

Print n numbers — the sought disposition with the minimum divisor number. The j-th number (1 ≤ j ≤ n) should be equal to p(j) — the number of tome that stands on the j-th place. If there are several solutions, print any of them.

输出 n 个数——即所求的、具有最小约数编号的排列。第 j 个数(1 ≤ j ≤ n)应等于 p(j),即排在第 j 个位置上的典籍编号。若存在多个解,输出其中任意一个即可。

输入输出样例

  • 输入#1

    2

    输出#1

    2 1
  • 输入#2

    3

    输出#2

    1 3 2

输入解题思路,AI测评打分。不知道怎么写?

首页