301182: CF221A. Little Elephant and Function
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Little Elephant and Function
题意翻译
#### 题目背景 小象有一个递归函数 #### 题目描述 小象很喜欢对一个升序序列进行编辑,它有一个包含$1$-$n$共$n$个整数的升序序列。$a_i$代表这个序列中第$i$个数。小象的递归函数$f(x)$工作原理如下: - 如果$x=1$,退出函数 - 否则,调用$f(x-1)$,并且交换($a_{x-1},a_x$)(先进行$swap$) 请帮助小象输出运行函数后数列的结果。 #### 输入格式 只有一个整数$n$($1 \leq n \leq 1000$)。意义如题目描述 #### 输出格式 $n$个整数,表示排序后的序列题目描述
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 single line contains integer $ n $ $ (1<=n<=1000) $ — the size of permutation.
输出格式
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.
输入输出样例
输入样例 #1
1
输出样例 #1
1
输入样例 #2
2
输出样例 #2
2 1