#P5904. [POI 2014] HOT-Hotels 加强版
[POI 2014] HOT-Hotels 加强版
Background
Same as [POI2014]HOT-Hotels, but the Constraints are increased to .
Source: BZOJ4543.
Problem Description
Given a tree with nodes, find how many triples of nodes satisfy that the distances between every pair among are all equal.
and are considered the same triple.
Input Format
The first line contains an integer .
The next lines each contain two integers , meaning there is an edge between and .
Output Format
Output one integer in one line, representing the number of all valid triples of nodes.
7
1 2
5 7
2 5
2 3
5 6
4 5
5
Hint
For of the testdata, .
Translated by ChatGPT 5