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

Разделы > Linear Data Structures: Arrays > задача:


51130 - Permutation of Everything

Задачи раздела

• CEN - Question 1
• 51107 - Factorial
• Reflektimi i pikes
• 50972 - Division
• Question 1
• 51135 - Class Average 1
• 51136 - Class Average 2
• 51094 - Passing the course
• 51130 - Permutation of Everything
• 51069 - Last Digit of a Fibonacci Nu...
• 51073 - Campus Tours for High Sch...
• 51148 - Circles
• 51123 - Mr. Li Criteria
• 51124 - Easy Tiae words
• 51145 - Graduation Exam
• 51117 - The Most Crowded
• 51146 - Popular Baby Names

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

Если у вас есть предложения или пожелания по работе 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