HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > IMPC - 2013-2014 > problem:


14-03-30. 50377 - kth Permutation

IMPC - 2013-2014

Start: Mar.16.2013 at 12:00:00 PM
Finish: Mar.16.2013 at 05:00:00 PM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (1)

Contest problems

• 50386 - Conformity
• 14-01-10. 50457 - The Number of W...
• 14-01-40. 50419 - The longest bitoni...
• 14-01-50. 50795 - Trunk
• 14-03-10. 50412 - K numbers
• 14-03-20. 50398 - Sum of kth Anti-d...
• 14-03-30. 50377 - kth Permutation
• 14-03-40. 50773 - Balanced Sum Tree
• 14-03-60. 50382 - Parkside's Other ...
• 14-03-70. 50468 - Draw Matrix - 2
• 14-03-70. 50468 - Draw Matrix - 2
• 14-03-80. 50675 - Kruja Boys
• 14-03-90. 50717 - Hurdle Jumping
• 14-04-20. 50493 - n-digit kth Prime ...
• 14-04-30. 50669 - Area of an Irregu...

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Adapted from from Mongolian National Informatics Olympiads.

kth Permutation

In mathematics, the permutation is the rearranging or repositioning of objects or values.

Question: Write a program that gets the length of a the permuted elements (numbers) and a number k. Then, your program will show kth positioning of the numbers.
The positioning starts with ascending order of all numbers and goes always in ascending order. For example, if n is 5, the first 9 permutations can be listed as follows:
 1. 1 2 3 4 5
 2. 1 2 3 5 4
 3. 1 2 4 3 5
 4. 1 2 4 5 3
 5. 1 2 5 3 4
 6. 1 2 5 4 3
 7. 1 3 2 4 5
 8. 1 3 2 5 4
 9. 1 3 4 2 5

Input specification
You will be given only two integer numbers (n and k) where 1 ≤ n ≤ 30 and 1 ≤ k ≤ 1016 and k is less than or equal to n!.

Output specification
Show kth positioning of n numbers.

 Sample Input I  
  5 2
 Sample Input II  
  6 23
 Sample Output I  
  1 2 3 5 4
 Sample Output II  
  1 2 6 5 3 4


Для отправки решений необходимо выполнить вход.

www.contester.ru