

Time Limit: 4 sec / Memory Limit: 1024 MB
配点 : 点
問題文
正の整数 が与えられるので、 以上 以下の全ての整数 について、次の問題を解いてください。
- の各整数をそれぞれ 個以上 個以下含むような空でない多重集合であって、平均が であるものの個数を で割った余りを求めよ。
制約
- は素数である
- 入力は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
出力
以下の形式で出力せよ。
ただし は、平均が である多重集合の個数を で割った余りを表す。
入力例 1Copy
3 1 998244353
出力例 1Copy
1 3 1
以上 以下の整数をそれぞれ 個以上 個以下含むような空でない多重集合を考えます。
- 平均が である多重集合は、 の 個です。
- 平均が である多重集合は、 の 個です。
- 平均が である多重集合は、 の 個です。
入力例 2Copy
1 2 1000000007
出力例 2Copy
2
以上 以下の整数をそれぞれ 個以上 個以下含むような空でない多重集合を考えます。
- 平均が である多重集合は、 の 個です。
入力例 3Copy
10 8 861271909
出力例 3Copy
8 602 81827 4054238 41331779 41331779 4054238 81827 602 8
Score : points
Problem Statement
Given positive integers and , solve the following problem for every integer between and (inclusive):
- Find the number, modulo , of non-empty multisets containing between and (inclusive) instances of each of the integers such that the average of the elements is .
Constraints
- is prime.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Use the following format:
Here, should be the number, modulo , of multisets such that the average of the elements is .
Sample Input 1Copy
3 1 998244353
Sample Output 1Copy
1 3 1
Consider non-empty multisets containing between and instance(s) of each of the integers between and . Among them, there are:
- one multiset such that the average of the elements is : ;
- three multisets such that the average of the elements is : ;
- one multiset such that the average of the elements is : .
Sample Input 2Copy
1 2 1000000007
Sample Output 2Copy
2
Consider non-empty multisets containing between and instances of each of the integers between and . Among them, there are:
- two multisets such that the average of the elements is : .
Sample Input 3Copy
10 8 861271909
Sample Output 3Copy
8 602 81827 4054238 41331779 41331779 4054238 81827 602 8