atcoder#ARC160D. [ARC160D] Mahjong

[ARC160D] Mahjong

Score : 700700 points

Problem Statement

Find the number, modulo 998244353998244353, of sequences of NN non-negative integers A=(A1,A2,,AN)A=(A_1,A_2,\dots,A_N) totaling MM that satisfy the following condition.

  • It is possible to make all elements of AA equal 00 by repeatedly choosing one of the following operations and performing it.- Choose an integer ii such that 1iN1 \le i \le N and decrease AiA_i by KK.
    • Choose an integer ii such that 1iNK+11 \le i \le N-K+1 and decrease each of Ai,Ai+1,,Ai+K1A_i,A_{i+1},\dots,A_{i+K-1} by 11.
  • Choose an integer ii such that 1iN1 \le i \le N and decrease AiA_i by KK.
  • Choose an integer ii such that 1iNK+11 \le i \le N-K+1 and decrease each of Ai,Ai+1,,Ai+K1A_i,A_{i+1},\dots,A_{i+K-1} by 11.

Constraints

  • 1KN20001 \le K \le N \le 2000
  • 1M10181 \le M \le 10^{18}

Input

The input is given from Standard Input in the following format:

NN MM KK

Output

Print the answer.

3 2 2
5

The following five sequences satisfy the requirements.

  • (1,1,0)(1,1,0)
  • (0,1,1)(0,1,1)
  • (2,0,0)(2,0,0)
  • (0,2,0)(0,2,0)
  • (0,0,2)(0,0,2)

For instance, if A=(0,1,1)A=(0,1,1), you can do the following to make all elements of AA equal 00.

  • Perform the second operation. Choose i=2i = 2 to decrease each of A2A_2 and A3A_3 by 11, making A=(0,0,0)A=(0,0,0).
100 998244353 100
0

There may be no sequence that satisfies the requirements.

2000 545782618661124208 533
908877889