A. Little elephant and Function

Source: Internet
Author: User
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;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.