当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5187:zhx's contest

题目描述
As one of the most powerful brushes, zhx is required to give his juniors $n$ problems.
zhx thinks the $i^{th}$ problem's difficulty is $i$. He wants to arrange these problems in a beautiful way.
zhx defines a sequence $\{a_{i}\}$ beautiful if there is an $i$ that matches two rules below:
1: $a_{1} .. a_{i}$ are monotone decreasing or monotone increasing.
2: $a_{i} .. a_{n}$ are monotone decreasing or monotone increasing.
He wants you to tell him that how many permutations of problems are there if the sequence of the problems' difficulty is beautiful.
zhx knows that the answer may be very huge, and you only need to tell him the answer module $p$.
输入解释
Multiply test cases(less than $1000$). Seek $EOF$ as the end of the file.
For each case, there are two integers $n$ and $p$ separated by a space in a line. ($1 \leq n,p \leq 10^{18}$)
输出解释
For each test case, output a single line indicating the answer.
输入样例
2 233
3 5
输出样例
2
1

提示
In the first case, both sequence {1, 2} and {2, 1} are legal.
In the second case, sequence {1, 2, 3}, {1, 3, 2}, {2, 1, 3}, {2, 3, 1}, {3, 1, 2}, {3, 2, 1} are legal, so the answer is 6 mod 5 = 1
来自杭电HDUOJ的附加信息
Recommend hujie

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 BestCoder Round #33

源链接: HDU-5187

最后修改于 2020-10-25T23:20:32+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/65536K(Java/Others)