atcoder#ARC151B. [ARC151B] A < AP
[ARC151B] A < AP
Score : points
Problem Statement
You are given a permutation of .
Print the number of integer sequences of length that satisfy both of the conditions below, modulo .
- for every .
- The integer sequence is lexicographically smaller than the integer sequence .
What is lexicographical order?
An integer sequence is lexicographically smaller than an integer sequence when there is an integer that satisfies both of the conditions below.
- For all integers (), .
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the number of integer sequences of length that satisfy both of the conditions in the Problem Statement, modulo .
4 2
4 1 3 2
6
Six integer sequences satisfy both of the conditions: , , , , , and . For instance, when , we have $(A_{P_1}, A_{P_2}, A_{P_3}, A_{P_4}) = (2, 1, 1, 1)$, which is lexicographically larger than .
1 1
1
0
20 100000
11 15 3 20 17 6 1 9 5 19 10 16 7 8 12 2 18 14 4 13
55365742