#abc222d. D - Between Two Arrays
D - Between Two Arrays
Score : points
问题描述
若一个包含 个数的序列 满足对于所有 都有 ,则称该序列为 非递减 序列。
已知两个均为非递减序列的整数序列: 和 。
考虑一个满足以下条件的包含 个整数的非递减序列 :
- 对于所有 ,都有 。
求出可能成为序列 的序列数量,结果对 取模。
以上为通义千问 qwen-max 翻译,仅供参考。
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 .
Sample Input 1
2
1 1
2 3
Sample Output 1
5
There are five sequences that can be , as follows.
Note that does not satisfy the condition since it is not non-decreasing.
Sample Input 2
3
2 2 2
2 2 2
Sample Output 2
1
There is one sequence that can be , as follows.
Sample Input 3
10
1 2 3 4 5 6 7 8 9 10
1 4 9 16 25 36 49 64 81 100
Sample Output 3
978222082
Be sure to find the count modulo .
update @ 2024/3/10 09:47:11