AtCoder Grand Contest 041
D
Problem Scores
AtCoder
⌀ 3096
原题
← CE →
翻译中…

Problem Statement

翻译中…

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

翻译中…

Problem $i$ must get an integer score $A_i$ between $1$ and $N$, inclusive. The problems have already been sorted by difficulty: $A_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 $k$ ($1 \le k \le N-1$), you want the sum of scores of any $k$ problems to be strictly less than the sum of scores of any $k+1$ problems.

翻译中…

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

翻译中…

Constraints

翻译中…
  • $2 \leq N \leq 5000$
  • $9 \times 10^8 < M < 10^9$
  • $M$ is a prime.
  • All input values are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N M

翻译中…

Output

翻译中…

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

翻译中…

样例

Input #1
2 998244353
Output #1
3
The possible assignments are $(1, 1)$, $(1, 2)$, $(2, 2)$.
Input #2
3 998244353
Output #2
7
The possible assignments are $(1, 1, 1)$, $(1, 2, 2)$, $(1, 3, 3)$, $(2, 2, 2)$, $(2, 2, 3)$, $(2, 3, 3)$, $(3, 3, 3)$.
Input #3
6 966666661
Output #3
66
Input #4
96 925309799
Output #4
83779
题目信息
题号
agc041_d
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。