#abc173f. [abc173_f]Intervals on Tree
[abc173_f]Intervals on Tree
Problem Statement
We have a tree with vertices and edges, respectively numbered and . Edge connects Vertex and .
For integers (), let us define a function as follows:
- Let be the set of the vertices numbered through . represents the number of connected components in the subgraph formed only from the vertex set and the edges whose endpoints both belong to .
Compute .
Constraints
- The given graph is a tree.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print .
Sample Input 1
3
1 3
2 3
Sample Output 1
7
We have six possible pairs as follows:
- For , and we have connected component.
- For , and we have connected components.
- For , and we have connected component, since contains both endpoints of each of the edges .
- For , and we have connected component.
- For , and we have connected component, since contains both endpoints of Edge .
- For , and we have connected component.
The sum of these is .
Sample Input 2
2
1 2
Sample Output 2
3
Sample Input 3
10
5 3
5 7
8 9
1 9
9 10
8 4
7 4
6 10
7 2
Sample Output 3
113