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

建议使用的浏览器:

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

4623:Crime

题目描述
You kill a person and will be executed by shooting tomorrow,but you have a program contest to do today,after several hours' hard work,you solved all problems except this one.You died with the pity that didn't solved it.But now you have second chance.
Count the number of permutation of number 1 to n that every adjacent number are coprime.To avoid large number,output the result mod a number M.
输入解释
The first line contains integer T(1<=T<=5).Denoting the number of the test cases.
Then T lines follows,each line contains two integers n,M (1<=n<=28, 1<=M<=30000).
The n for each test cases will not be the same.
输出解释
For each test cases,print the answer in a line.
输入样例
5
1 10000
2 10000
3 10000
4 10000
5 10000
输出样例
1
2
6
12
72
提示
There is a solution without making table.
Two integers are coprime if their greatest common divisor is 1.
来自杭电HDUOJ的附加信息
Author WJMZBMR
Recommend zhuyuanchen520

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

源链接: HDU-4623

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

共提交 0

通过率 --%
时间上限 内存上限
60000/30000MS(Java/Others) 655360/327680K(Java/Others)