HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Arithmetic > problem:


50377 - kth Permutation

Guest
• Review clarifications (1)

Section problems

• 50812 - Total Discount for the clients
• 50435 - City Electric Bills
• 50527 - Sum of LCMs
• 50539 - Number of Chairs - 2
• 50532 - Close City
• 50379 - a^b modulus k
• 50404 - Sum of Self Powers
• 50403 - Number of Chairs
• 50377 - kth Permutation
• Cineplexx
• Cirku Belluci
• 50896 - Sum of Even Numbers
• 50903 - Basic Math Calculator
• El Clasico
• 50657 - Permutations and Combinat...
• 50659 - Covariance Matrix
• 50658 - The Message

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