Time limit per test
2 seconds
Memory limit per test
256 megabytes
Input
Standard Input
Output
Standard output
The little elephant enjoys recursive functions.
This time he enjoys the sorting function. LetAIs a permutation of an integers from 1N,
Comprehensive, andAIDenotes
TheI-Th element of the permutation. The little elephant's Recursive FunctionF(X),
That sorts the firstXPermutation's elements, works as follows:
- IfXWhen = when 1, exit the function.
- Otherwise, callF(XAudio-extract 1), and then makeSwap(AXAccept-limit 1, limit,AX) (Swap
TheX-Th and (XPercent-Second 1)-th
ElementsA).
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 1N,
Such that after creating the little elephant's function (that is callF(N), The permutation will be sorted in ascending order.
Input
A single line contains integerN(1 digit ≤ DigitNLimit ≤ limit 1000 )-
The size of permutation.
Output
In a single line printNDistinct integers from 1N-
The required permutation. numbers in a line shocould be separated by spaces.
It is guaranteed that the answer exists.
Sample test (s) Input
1
Output
1
Input
2
Output
2 1
Solution Description: this is to find a regular expression from a small data size. Because of recursive operations, there is similarity. When n = 2 is, 2 1 can get data arranged from small to large, when n = 3, analysis shows that only the combination of 3 1 2 can get the result, and when n = 4, only 4 1 2 3 can get the result, it can be inferred that the data is n 1 2... n-1.
#include <iostream>#include<cstdio>#include<cstring>#include<cmath>using namespace std;int main(){int n,i;scanf("%d",&n);printf("%d ",n);for(i=1;i<n;i++){printf("%d ",i);}return 0;}