HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


50384 - Permutations revisited

Guest
• Review clarifications (1)

Volume problems

• 50382 - Parkside's Other Triangle
• 50377 - kth Permutation
• 50304 - Number Pattern
• 50322 - Snake Pattern
• 50321 - Missing Number
• 50317 - Student Line Up
• 50311 - Student Line Up
• 50384 - Permutations revisited
• 50841 - My grand-grand-grandfather
• 50380 - Sum of the Numbers in the ...
• 50395 - Page "Like" Averages
• 50332 - Variance of a series
• 50398 - Sum of kth Anti-diagonal
• 50323 - Filtering Contact List
• 50400 - nth Row rth Element of a Table
• 50364 - Student averages

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.
Prepared by Ibrahim Mesecan.

Permutations revisited

 

In previous contest you were asked to find the k-th permutation of a series in lexicographical order, for a given k. Now, we are asking for the inverse: you are given a permuted series, and you need to output its order. The inputs admit that k can have at most 15 digits.

 

Sample Input 1                                  Sample Output 1

4                                                          8

2 1 4 3

 

Sample Input 2                                  Sample Output 2

5                                                          110

5 3 1 4 2

 

Explanation for sample output 1:

1 2 3 4  // First permutation

1 2 4 3

1 3 2 4

1 3 4 2

1 4 2 3

1 4 3 2

2 1 3 4

2 1 4 3   // 8th permutation

 

Äëÿ îòïðàâêè ðåøåíèé íåîáõîäèìî âûïîëíèòü âõîä.

www.contester.ru