Resistance

TimeLimit:2000MS  MemoryLimit:65536KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
You are given a cactus with $n$ vertices and $m$ edges. There is a 1 Ohm resistor on every edge.

Let $f(s,t)$ be the equivalent resistance between the vertex $s$ and the vertex $t$.

Print $\sum_{1\leq s<t\leq n} f(s,t)$.

Note: a cactus (sometimes called a cactus tree) is a connected graph in which any two simple cycles have at most one vertex in common. Equivalently, it is a connected graph in which every edge belongs to at most one simple cycle.
Input
The first line contains one integer $T (1\leq T\leq 7)$ - the number of the test cases.

For each test case, the first line contains two integers $n,m(1\leq n\leq 2 \times 10^5, 1\leq m\leq 4\times 10^5)$.

Each of the following $m$ lines contains three integers $u,v (1\leq u\neq v\leq n)$.
Output
For each test case, print the answer modulo $10^9+7$. That is,the answer can be represented as a fraction $a/b$ where $(a,b)=1$, output $c(0\leq c<10^9+7)$ such that $bc \equiv a \pmod {10^9+7}$.
SampleInput
1
4 4
1 2
1 3
2 3
1 4
SampleOutput
333333342
Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数0
总提交量0
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: