#arc174e. E - Existence Counting
E - Existence Counting
Score: points
问题陈述
给定整数 和 。考虑一个长度为 的序列 ,它满足以下所有条件:
- 是一个整数,使得 。
- 中的所有元素都是不同的。
让我们将所有可能的序列 按字典序排列,形成一个称为字典 的“序列序列”。
给定一个存在于字典 中的序列 ,对于每个整数 ,回答以下问题:
- 找出满足以下所有条件的序列 的数量,对 取模:
- 序列 存在于字典 中。
- 整数 包含在序列 中。
- 序列 字典序小于或等于序列 。
序列的字典序是什么?如果满足以下 1. 或 2. 中的任一条件,则序列 严格字典序小于 :
- 且 。
- 存在一个整数 ,满足以下两个条件:
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given integers and . Consider a sequence of length that satisfies all of the following conditions:
- is an integer such that .
- All elements in are different.
Let us arrange all possible sequences in lexicographical order to form a "sequence of sequences" called the dictionary .
Given a sequence that exists in the dictionary , answer the following question for each integer :
- Find the number, modulo , of sequences that satisfy all of the following conditions:
- The sequence exists in the dictionary .
- The integer is contained in the sequence .
- The sequence is lexicographically less than or equal to the sequence .
What is lexicographical order for sequences? A sequence is lexicographically strictly less than if and only if 1. or 2. below is satisfied:
- and .
- There is an integer that satisfies both of the following:
Constraints
- All input values are integers.
- satisfies the condition in the problem statement.
Input
The input is given from Standard Input in the following format:
Output
Print lines in total.
The -th line should contain the answer to the problem for as an integer.
Sample Input 1
4 2
3 2
Sample Output 1
5
5
4
2
In this input, .
Here, the dictionary is $((1,2),(1,3),(1,4),(2,1),(2,3),(2,4),(3,1),(3,2),(3,4),(4,1),(4,2),(4,3))$.
Among the sequences in the dictionary that are lexicographically less than or equal to ,
- five sequences contain : ,
- five sequences contain : ,
- four sequences contain : ,
- two sequences contain : .
Sample Input 2
18 13
5 13 11 2 18 1 10 15 17 4 12 7 3
Sample Output 2
925879409
905921009
665544804
665544719
783035803
349952762
349952758
349952757
349952757
349921178
212092637
710350150
378895603
129113201
129111892
129098081
129096772
110181652