D - Multiset Mean Editorial /

Time Limit: 4 sec / Memory Limit: 1024 MB

配点 : 700700

問題文

正の整数 N,K,MN, K, M が与えられるので、11 以上 NN 以下の全ての整数 xx について、次の問題を解いてください。

  • 1,2,3,N1, 2, 3 \cdots, N の各整数をそれぞれ 00 個以上 KK 個以下含むような空でない多重集合であって、平均が xx であるものの個数を MM で割った余りを求めよ。

制約

  • 1N,K1001 \leq N, K \leq 100
  • 108M109+910^8 \leq M \leq 10^9 + 9
  • MM は素数である
  • 入力は全て整数である

入力

入力は以下の形式で標準入力から与えられる。

NN KK MM

出力

以下の形式で出力せよ。

c1c_1
c2c_2
::
cNc_N

ただし cxc_x は、平均が xx である多重集合の個数を MM で割った余りを表す。


入力例 1Copy

Copy
3 1 998244353

出力例 1Copy

Copy
1
3
1

11 以上 33 以下の整数をそれぞれ 00 個以上 11 個以下含むような空でない多重集合を考えます。

  • 平均が x=1x = 1 である多重集合は、{1}\{1\}11 個です。
  • 平均が x=2x = 2 である多重集合は、{2},{1,3},{1,2,3}\{2\}, \{1, 3\}, \{1, 2, 3\}33 個です。
  • 平均が x=3x = 3 である多重集合は、{3}\{3\}11 個です。

入力例 2Copy

Copy
1 2 1000000007

出力例 2Copy

Copy
2

11 以上 11 以下の整数をそれぞれ 00 個以上 22 個以下含むような空でない多重集合を考えます。

  • 平均が x=1x = 1 である多重集合は、{1},{1,1}\{1\}, \{1, 1\}22 個です。

入力例 3Copy

Copy
10 8 861271909

出力例 3Copy

Copy
8
602
81827
4054238
41331779
41331779
4054238
81827
602
8

Score : 700700 points

Problem Statement

Given positive integers N,KN, K and MM, solve the following problem for every integer xx between 11 and NN (inclusive):

  • Find the number, modulo MM, of non-empty multisets containing between 00 and KK (inclusive) instances of each of the integers 1,2,3,N1, 2, 3 \cdots, N such that the average of the elements is xx.

Constraints

  • 1N,K1001 \leq N, K \leq 100
  • 108M109+910^8 \leq M \leq 10^9 + 9
  • MM is prime.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK MM

Output

Use the following format:

c1c_1
c2c_2
::
cNc_N

Here, cxc_x should be the number, modulo MM, of multisets such that the average of the elements is xx.


Sample Input 1Copy

Copy
3 1 998244353

Sample Output 1Copy

Copy
1
3
1

Consider non-empty multisets containing between 00 and 11 instance(s) of each of the integers between 11 and 33. Among them, there are:

  • one multiset such that the average of the elements is k=1k = 1: {1}\{1\};
  • three multisets such that the average of the elements is k=2k = 2: {2},{1,3},{1,2,3}\{2\}, \{1, 3\}, \{1, 2, 3\};
  • one multiset such that the average of the elements is k=3k = 3: {3}\{3\}.

Sample Input 2Copy

Copy
1 2 1000000007

Sample Output 2Copy

Copy
2

Consider non-empty multisets containing between 00 and 22 instances of each of the integers between 11 and 11. Among them, there are:

  • two multisets such that the average of the elements is k=1k = 1: {1},{1,1}\{1\}, \{1, 1\}.

Sample Input 3Copy

Copy
10 8 861271909

Sample Output 3Copy

Copy
8
602
81827
4054238
41331779
41331779
4054238
81827
602
8


2025-04-07 (Mon)
22:02:32 +00:00