Title Description
Now gives a simple weighted undirected FIG. You are not satisfied with the minimum spanning tree calculated this figure, but would like to know how many different minimum spanning tree this figure there. (If there are at least two different sides of a minimum spanning tree, then both the minimum spanning tree is different). Since different minimum spanning tree may be a lot, so you only need to program the number of analog output 31011 on it.
Input Format
The first line contains two numbers, n and m, where 1 <= n <= 100; 1 <= m <= 1000; represents the number of nodes and edges in the undirected graph. Each node with an integer number of 1 ~ n.
The next m rows, each row comprising two integers: a, b, c, represents the node a, the right side between the b value c, where 1 <= c <= 1,000,000,000.
Data does not appear self-assurance back side and heavy side. Note: the same edge weight value is not more than 10.
Output Format
Different output minimum spanning tree how many. You only need to output the number of mold 31011 on it.
Sample input and output
4 6 1 2 1 1 3 1 1 4 1 2 3 2 2 4 1 3 4 1
8
Description / Tips
Description. 1 <= n-<= 100;. 1 <= m <= 1000; . 1 ≤ C I ≤ . 1 0 . 9
analysis
It's a wonderful storm search (?) Title
Yes, violent search, it is really a good algorithm
Positive Solutions What matrix tree, Gaussian elimination Han
I found the genre violence is abuse
First put a few well-written explanations:
Gangster problem solution 1hzwer
2luogu problem solution problem solution
3 magical solution to a problem of proof
How to search, a first conclusion:
For a minimum spanning tree alternate sides, there must be equal to the minimum spanning tree alternate edge side, and this side is connected with the communication with the two blocks
Therefore, various schemes for minimum spanning tree, the number of edges of the same length is the same
We can search storms (selected / not selected) to the sides of the same length, and finally determines whether the same number of minimum spanning tree to determine the legality '
Multiplication principle, the edge lengths of the various programs multiplying the number of programs to the final
For you, invincible!