时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld
题目描述
Given an undirected connected graph with

vertices and

edges, with no multiple edges or self-loops, find the sum of distances between every pair of vertices whose
degree is 
. The distance between two vertices is the minimum length among all simple paths between them. The length of a simple path is the number of edges on that path.
输入描述:
The first line contains an integer
(
).
The next
lines each contain two integers
(
), indicating an edge in the graph. It is guaranteed that there are no multiple edges in the graph.
输出描述:
Output a single integer representing the answer.
示例1
输入
复制
8
1 2
2 3
3 6
3 8
8 7
8 6
6 5
4 6
说明
The undirected connected graph described in the example is shown below.