#P6790. [SNOI2020] 生成树
[SNOI2020] 生成树
Problem Description
Given an undirected connected graph . It is known that after deleting one edge, becomes a cactus (cactus: an undirected connected graph in which no two simple cycles share a common edge). Find the number of spanning trees of . Output the result modulo .
Input Format
The first line contains two integers , denoting the number of vertices and edges of graph .
The next lines each contain two positive integers separated by a space , denoting an edge .
Output Format
Output one line with one integer, denoting the number of spanning trees of modulo .
4 5
1 2
1 3
2 3
2 4
3 4
8
Hint
Constraints: For all testdata, .
- For of the testdata, .
- For another of the testdata, and itself is a cactus.
- For the remaining of the testdata, there are no special constraints.
Translated by ChatGPT 5