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

Турниры > IMPC 2017 > задача:


6. 51130 - Permutation of Everything

IMPC 2017

Старт: 27.мая.2017 в 09:25:00
Финиш: 27.мая.2017 в 13:00:00
Турнир завершён!
• Турнирная таблица

Задачи турнира

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

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

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

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