atcoder#ABC217G. [ABC217G] Groups
[ABC217G] Groups
Score : points
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 .
4 2
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: .
6 6
1
31
90
65
15
1
You can divide them as you like.
20 5
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 .