HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > IMPC 2017 > problem:


6. 51130 - Permutation of Everything

IMPC 2017

Start: May.27.2017 at 09:25:00 AM
Finish: May.27.2017 at 01:00:00 PM
The contest is finished!
• Contest scoreboard

Contest problems

• 1. 51125 - Filling an Array 3
• 2. 51126 - Dr. Fllanxha
• 3. 51127 - Maze solver
• 5. 51129 - Hexagon
• 6. 51130 - Permutation of Ever...

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.
Question by Renato Bala.

Permutation of Everything

Combinatorics and Permutations are famous topics in mathematics. They get even more famous and fun when they are asked in homeworks. This exercise will ask you the permutation order number of the given digits.

If we have a three digits number '123' the first permutation is the number itself. The second permuation is '132', the third is '213' and so on. It comes in lexicographical order. But these exercise unlike the other permutation exercises in ACM comes with repeated digits. For example: The given number is '1223', the first permutation is the number itself, the second permutation is '1232', the third '1322', the fourth '2123' and so on.

Question:
Write a program that finds the permutation order number of the given digits.

Input specification:
You will be given an n (1 ≤ n ≤ 20) that is the number of digits and n digits (0 ≤ digit ≤ 9).

Output specification
Show a number the represents the order number of the permutation.

Sample Input I
4
2 1 3 2
Sample Input II
5
5 4 3 1 2
Sample Output I
5
Sample Output II
119


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

www.contester.ru