首页 > 其他 > 详细

Symmetric Matrix 牛客网暑期ACM多校训练营(第一场) B dp

时间:2018-07-20 16:25:16      阅读:191      评论:0      收藏:0      [点我收藏+]

 Count the number of n x n matrices A satisfying the following condition modulo m.

 * Ai, j ∈ {0, 1, 2} for all 1 ≤ i, j ≤ n.

 * Ai, j = Aj, i for all 1 ≤ i, j ≤ n.

 * Ai, 1 + Ai, 2 + ... + Ai, n = 2 for all 1 ≤ i ≤ n.  

* A1, 1 = A2, 2 = ... = An, n = 0.

 输入描述:  

The input consists of several test cases and is terminated by end-of-file.  Each test case contains two integers n and m.  

输出描述:

 For each test case, print an integer which denotes the result.  

备注  * 1 ≤ n ≤ 10  5  * 1 ≤ m ≤ 10  9  * The sum of n does not exceed 10  7  .  

示例1:

 输入

 3 1000000000

 100000 1000000000  

输出  

1  

507109376

 

Symmetric Matrix 牛客网暑期ACM多校训练营(第一场) B dp

原文:https://www.cnblogs.com/l609929321/p/9342000.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!