QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 100

#16220. 有趣的数列

Statistics

我们称一个长度为 $2n$ 的数列是有趣的,当且仅当该数列满足以下三个条件:

  1. 它是从 $1$ 到 $2n$ 共 $2n$ 个整数的一个排列 ${a_i}$;
  2. 所有的奇数项满足 $a_1 < a_3<\cdots< a_{2n-1}$,所有的偶数项满足 $a_2< a_4< \cdots< a_{2n}$;
  3. 任意相邻的两项 $a_{2i-1}$ 与 $a_{2i}$($1\le i\le n$)满足奇数项小于偶数项,即:$a_{2i-1}< a_{2i}$。

现在的任务是:对于给定的 $n$,求出有多少个不同的长度为 $2n$ 的有趣的数列。因为最后的答案可能很大,所以只要求输出答案 $\bmod\ P$ 的值。

输入格式

输入文件只包含用空格隔开的两个整数 $n$ 和 $P$。输入数据保证: 50% 的数据满足 $n\le 1000$,100% 的数据满足 $n\le 1000000$ 且 $P\le 1000000000$。

输出格式

输出仅包含一个整数,表示不同的长度为 $2n$ 的有趣的数列个数 $\bmod\ P$ 的值。

样例数据

input.txt

3 10

output.txt

5

输入输出样例说明

对应的 5 个有趣的数列分别为 $(1,2,3,4,5,6)$,$(1,2,3,5,4,6)$,$(1,3,2,4,5,6)$,$(1,3,2,5,4,6)$,$(1,4,2,5,3,6)$。

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.