ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Сборники > Array_and_Matrices > задача:


50053 - kth Permutation

Задачи сборника

• 50016 - Student Line Up
• 50021 - Student Line Up
• 50023 - Missing Number
• 50024 - Snake Pattern
• 50026 - Variance of a series
• 50030 - Exam Averages
• 50032 - 100 Factorial
• 50046 - Student averages
• 50053 - kth Permutation
• 50057 - Parkside's Other Triangle
• 50065 - Page "Like" Ave...
• 50068 - Sum of kth Anti-diagonal
• 50072 - Draw Pattern 178
• 50073 - Missing Number
• 50076 - Zero Padding
• 50077 - Valid Permutations
• 50080 - Student averages

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
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