#P5296. [北京省选集训2019] 生成树计数
[北京省选集训2019] 生成树计数
Description
Little S has just learned about spanning trees. Being clever, he came up with a question:
Given a weighted undirected complete graph with vertices, find the sum of the -th powers of the weights of all spanning trees.
The weight of a tree is defined as the sum of the weights of all its edges.
Since he cannot solve it, you have to do it.
Because the answer may be very large, output the result modulo .
Input Format
The first line contains two non-negative integers , as described above.
The next lines each contain integers, representing the adjacency matrix of this weighted undirected complete graph.
Let denote the entry in row and column of the matrix, and it is guaranteed that:
, and .
Output Format
Output one line containing one integer, representing the answer modulo .
3 1
0 0 1
0 0 1
1 1 0
4
Hint
Constraints:
For of the testdata: .
For another of the testdata: .
For another of the testdata: .
For of the testdata: .
For another of the testdata: .
For of the testdata: , , .
Note that .
Translated by ChatGPT 5
京公网安备 11011102002149号