CF221A.Little Elephant and Function
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The Little Elephant enjoys recursive functions.
This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and a__i denotes the i-th element of the permutation. The Little Elephant's recursive function f(x), that sorts the first x permutation's elements, works as follows:
- If x = 1, exit the function.
- Otherwise, call f(x - 1), and then make swap(a__x - 1, a__x) (swap the x-th and (x - 1)-th elements of a).
The Little Elephant's teacher believes that this function does not work correctly. But that-be do not get an F, the Little Elephant wants to show the performance of its function. Help him, find a permutation of numbers from 1 to n, such that after performing the Little Elephant's function (that is call f(n)), the permutation will be sorted in ascending order.
小象喜欢递归函数。
这一次,他喜欢排序函数。设 $ a $ 是一个由 $ 1 $ 到 $ n (含)的整数构成的排列, a_i $ 表示该排列中第 $ i $ 个元素。小象的递归函数 $ f(x) $ 用于对排列的前 $ x $ 个元素进行排序,其工作方式如下:
- 若 $ x = 1 $,则退出函数;
- 否则,先调用 $ f(x - 1) $,然后执行 $ \text{swap}(a_{x-1},, a_x) $(即交换 $ a $ 中第 $ x $ 个与第 $ x-1 $ 个元素)。
小象的老师认为该函数不能正确工作。但为了不拿到 F 成绩,小象希望展示其函数的实际运行效果。请你帮助他,找出一个 $ 1 $ 到 $ n $ 的排列,使得在执行小象的函数(即调用 $ f(n) $)之后,该排列按升序排列。
输入格式
A single line contains integer n (1 ≤ n ≤ 1000) — the size of permutation.
一行包含一个整数 n(1 ≤ n ≤ 1000)——排列的大小。
输出格式
In a single line print n distinct integers from 1 to n — the required permutation. Numbers in a line should be separated by spaces.
It is guaranteed that the answer exists.
在一行中输出 n 个互不相同的整数,取值范围为 1 到 n —— 即所要求的排列。同一行中的数字之间用空格分隔。
保证答案存在。
输入输出样例
输入#1
1
输出#1
1
输入#2
2
输出#2
2 1
输入解题思路,AI测评打分。不知道怎么写?