#P5367. 【模板】康托展开
【模板】康托展开
Problem Description
Find the rank of a given permutation of among all permutations of . Output the result modulo .
Input Format
The first line contains a positive integer .
The second line contains positive integers, representing a permutation of .
Output Format
Output one non-negative integer, the answer modulo .
3
2 1 3
3
4
1 2 4 3
2
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, .
Translated by ChatGPT 5