atcoder#ABC222D. [ABC222D] Between Two Arrays
[ABC222D] Between Two Arrays
Score : points
Problem Statement
A sequence of numbers, , is said to be non-decreasing if and only if holds for every .
Given are non-decreasing sequences of integers each: and . Consider a non-decreasing sequence of integers, , that satisfies the following condition:
- for every .
Find the number, modulo , of sequences that can be .
Constraints
- The sequences and are non-decreasing.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number, modulo , of sequences that can be .
2
1 1
2 3
5
There are five sequences that can be , as follows.
Note that does not satisfy the condition since it is not non-decreasing.
3
2 2 2
2 2 2
1
There is one sequence that can be , as follows.
10
1 2 3 4 5 6 7 8 9 10
1 4 9 16 25 36 49 64 81 100
978222082
Be sure to find the count modulo .