#abc217g. G - Groups
G - Groups
Score : points
问题描述
给定正整数 和 ,对于每个 ,解决以下问题:
- 问题:我们将 ID 号从 1 到 的 个人分成 个非空组。这里,ID 号对 取模相等的人不能在同一组中。
- 如何将人分成组的方案有多少种?
- 由于答案可能非常大,求解结果对 取模。
这里,两种划分人群的方式被认为是不同的,当存在一对 ,使得在一种划分方式中,Person 和 Person 在同一组,而在另一种划分方式中不在同一组时。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given positive integers and . For each , solve the following problem.
- Problem: We will divide people with ID numbers through into non-empty groups. Here, people whose ID numbers are equal modulo cannot belong to the same group.
How many such ways are there to divide people into groups?
Since the answer may be enormous, find it modulo .
Here, two ways to divide people into groups are considered different when there is a pair such that Person and Person belong to the same group in one way but not in the other.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines.
The -th line should contain the answer for the problem with .
Sample Input 1
4 2
Sample Output 1
0
2
4
1
People whose ID numbers are equal modulo cannot belong to the same group. That is, Person and Person cannot belong to the same group, and neither can Person and Person .
- There is no way to divide the four into one group.
- There are two ways to divide the four into two groups: and .
- There are four ways to divide the four into three groups: , , , and .
- There is one way to divide the four into four groups: .
Sample Input 2
6 6
Sample Output 2
1
31
90
65
15
1
You can divide them as you like.
Sample Input 3
20 5
Sample Output 3
0
0
0
331776
207028224
204931064
814022582
544352515
755619435
401403040
323173195
538468102
309259764
722947327
162115584
10228144
423360
10960
160
1
Be sure to find the answer modulo .
update @ 2024/3/10 09:37:40