atcoder#AGC041D. [AGC041D] Problem Scores

[AGC041D] Problem Scores

Score : 12001200 points

Problem Statement

NN problems have been chosen by the judges, now it's time to assign scores to them!

Problem ii must get an integer score AiA_i between 11 and NN, inclusive. The problems have already been sorted by difficulty: A1A2ANA_1 \le A_2 \le \ldots \le A_N must hold. Different problems can have the same score, though.

Being an ICPC fan, you want contestants who solve more problems to be ranked higher. That's why, for any kk (1kN11 \le k \le N-1), you want the sum of scores of any kk problems to be strictly less than the sum of scores of any k+1k+1 problems.

How many ways to assign scores do you have? Find this number modulo the given prime MM.

Constraints

  • 2N50002 \leq N \leq 5000
  • 9×108<M<1099 \times 10^8 < M < 10^9
  • MM is a prime.
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

NN MM

Output

Print the number of ways to assign scores to the problems, modulo MM.

2 998244353
3

The possible assignments are (1,1)(1, 1), (1,2)(1, 2), (2,2)(2, 2).

3 998244353
7

The possible assignments are (1,1,1)(1, 1, 1), (1,2,2)(1, 2, 2), (1,3,3)(1, 3, 3), (2,2,2)(2, 2, 2), (2,2,3)(2, 2, 3), (2,3,3)(2, 3, 3), (3,3,3)(3, 3, 3).

6 966666661
66
96 925309799
83779