221A.md (1445B)
1 Source: https://codeforces.com/problemset/problem/221/A 2 3 A. Little Elephant and Function 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 The Little Elephant enjoys recursive functions. 22 23 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: 24 25 * If *x* = 1, exit the function. 26 * 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*). 27 28 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. 29 30 Input 31 32 A single line contains integer *n* (1 ≤ *n* ≤ 1000) — the size of permutation. 33 34 Output 35 36 In a single line print *n* distinct integers from 1 to *n* — the required permutation. Numbers in a line should be separated by spaces. 37 38 It is guaranteed that the answer exists. 39 40 Examples 41 42 Input 43 44 ``` 45 1 46 ``` 47 48 Output 49 50 ``` 51 1 52 ``` 53 54 Input 55 56 ``` 57 2 58 ``` 59 60 Output 61 62 ``` 63 2 1 64 ```