#P7442. [2017年杭电多校]I Curse Myself
[2017年杭电多校]I Curse Myself
I Curse Myself
Problem Description
There is a connected undirected graph with weights on its edges. It is guaranteed that each edge appears in at most one simple cycle. Assuming that the weight of a weighted spanning tree is the sum of weights on its edges, define as the weight of the -th smallest weighted spanning tree of this graph, however, would be defined as zero if there did not exist different weighted spanning trees. Please calculate $\displaystyle\left(\sum_{k=1}^{K}{k \cdot V(k)}\right) \bmod 2^{32}$.
Input
The input contains multiple test cases. For each test case, the first line contains two positive integers , the number of nodes and the number of edges of this graph. Each of the next lines contains three positive integers , meaning an edge weighted between node and node . There does not exist multi-edge or self-loop in this graph. The last line contains a positive integer .
Output
For each test case, output " Case #: " in one line (without quotes), where indicates the case number starting from and denotes the answer of corresponding case.
Sample Input
4 3
1 2 1
1 3 2
1 4 3
1
3 3
1 2 1
2 3 2
3 1 3
4
6 7
1 2 4
1 3 2
3 5 7
1 5 3
2 4 1
2 6 2
6 4 5
7
Sample Output
Case #1: 6
Case #2: 26
Case #3: 493
Source
2017 Multi-University Training Contest - Team 1