编程介的小学生 2017-08-28 11:26 采纳率: 20.5%
浏览 744
已采纳

Crime

Problem Description
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.

Input
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.

Output
For each test cases,print the answer in a line.

Sample Input
5
1 10000
2 10000
3 10000
4 10000
5 10000

Sample Output
1
2
6
12
72

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码