#abc327g. G - Many Good Tuple Problems
G - Many Good Tuple Problems
Score : points
问题描述
在本题中,好的序列对的定义与问题D中的相同。
当满足以下条件时,长度为且包含不大于的正整数的两个序列$(S, T) = ((S_1, S_2, \dots, S_M), (T_1, T_2, \dots, T_M))$被称作好的序列对。
- 存在一个由0和1组成的长度为的序列,满足以下条件:
- 对于每个,有。
在所有可能的由不大于的正整数组成的长度为的序列对$(A, B) = ((A_1, A_2, \dots, A_M), (B_1, B_2, \dots, B_M))$中,求出(模)满足是好的序列对的数量。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
The definition of a good pair of sequences in this problem is the same as in Problem D.
A pair of sequences of length consisting of positive integers at most , $(S, T) = ((S_1, S_2, \dots, S_M), (T_1, T_2, \dots, T_M))$, is said to be a good pair of sequences when satisfies the following condition.
- There exists a sequence of length consisting of and that satisfies the following condition:
- for each .
Among the possible pairs of sequences of length consisting of positive integers at most , $(A, B) = ((A_1, A_2, \dots, A_M), (B_1, B_2, \dots, B_M))$, find the number, modulo , of those that are good pairs of sequences.
Constraints
- and are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the number, modulo , of pairs of sequences of length consisting of positive integers at most that are good pairs of sequences.
Sample Input 1
3 2
Sample Output 1
36
For example, if , then is a good pair of sequences. Indeed, if we set , then is a sequence of length consisting of and that satisfies and . Thus, satisfies the condition of being a good pair of sequences.
There are a total of good pairs of sequences, so print this number.
Sample Input 2
3 3
Sample Output 2
168
Sample Input 3
12 34
Sample Output 3
539029838
Sample Input 4
20 231104
Sample Output 4
966200489
update @ 2024/3/10 01:52:05