0122. Generation of a Permutation
Input file name: | gen.in |
Output file name: | gen.out |
Time limit: | 500 ms |
Memory limit: | 64 megabytes |
Generate a permutation of 1 ≤ N ≤ 100 elements by its lexicographical number 1 ≤ K ≤ N!.
Input file
The only line of input contains N and K separated by an arbitrary number of whitespace characters.
Output file
In the only line of output file print N different integers x1,…,xN ranging from one to N, separated by single spaces. No trailing spaces are allowed.
Examples:
gen.in | gen.out |
---|---|
3 2 | 1 3 2 |
Source: Petrozavodsk Summer 2003. Blitz Kontest, Monday, August 25
Author: Andrew Lopatin, Nick Durov
Discuss Submit a solution
Printable version