链接: https://www.nowcoder.com/acm/contest/139/B 题意: 求满足以下条件的n*n矩阵A的数量模m:A(i,j) ∈ {0,1,2}, 1≤i,j≤n.A(i,j) = A(j,i), 1≤i,j≤n.A(i,1) + A(i,2) + ... + A(i,n) = 2, 1≤i≤n.A(1,1) = A(2,2) = ... = A(n,n) = 0.其中1≤n≤1e5, 1≤m≤1e9. 分析: 把矩阵看成无向图的邻接矩阵,即要求所有点度为2,即每个…