atcoder#ARC146E. [ARC146E] Simple Speed
[ARC146E] Simple Speed
Score : points
Problem Statement
You are given a sequence of positive integers: .
How many integer sequences consisting of integers between and (inclusive) satisfy all of the following conditions? Print the count modulo .
- For each integer such that , there are exactly occurrences of in .
- For each integer such that , it holds that .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3
2 3 1
6
can be the following six sequences.
Thus, the answer is .
1
200000
0
There may be no sequence that satisfies the conditions.
6
12100 31602 41387 41498 31863 12250
750337372