QOJ.ac

QOJ

حد الوقت: 2.5 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓

#18262. 执拗者

الإحصائيات

你正在和 Akie 玩一个报数游戏。

游戏规则如下:你和 Akie 轮流报数,从你开始。每次,你可以报出 $1$ 到 $2n$ 之间任意一个尚未被报过的正整数。由于 Akie 天生胆小,她每次只会报出当前尚未被报过的最小正整数。游戏共进行 $n$ 轮,所有 $2n$ 个正整数都恰好被报出一次。

设 $S$ 为 Akie 报出的所有数字之和。如果 $S \ge k$,则 Akie 获胜。

给定常数 $k$,有多少种方案能让 Akie 获胜?答案对 $p$ 取模。两种方案被认为是不同的,当且仅当存在某一轮,你报出的数字不同,或者 Akie 报出的数字不同。

输入格式

一行,包含三个正整数 $n$、$k$ 和模数 $p$。

保证 $1 \le n \le 100$,$\frac{n(n+1)}{2} \le k \le n(n+1)$,$10^8 + 7 \le p \le 10^9 + 9$,且 $p$ 为质数。

输出格式

一个整数,表示答案。

样例

输入样例 1

2 4 998244353

输出样例 1

6

输入样例 2

5 20 1000000007

输出样例 2

2688

说明

当 $n = 2$ 时,所有可能被报出的数字序列为:$(1, 2, 3, 4)$,$(1, 2, 4, 3)$,$(2, 1, 3, 4)$,$(2, 1, 4, 3)$,$(3, 1, 2, 4)$,$(3, 1, 4, 2)$,$(4, 1, 2, 3)$,$(4, 1, 3, 2)$。其中第 2 个数字和第 4 个数字是由 Akie 报出的。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.