QOJ.ac

QOJ

Time Limit: 0.7 s Memory Limit: 64 MB Total points: 100

#11292. Hotels

Statistics

There are n towns in Byteotia, connected with only $n-1$ roads. Each road directly links two towns. All the roads have the same length and are two way. It is known that every town can be reached from every other town via a route consisting of one or more (direct-link) roads. In other words, the road network forms a tree.

Byteasar, the king of Byteotia, wants three luxury hotels erected to attract tourists from all over the world. The king desires that the hotels be in different towns and at the same distance one from each other.

Help the king out by writing a program that determines the number of possible locations of the hotel triplet in Byteotia.

Input Format

The first line of the standard input contains a single integer $n$ ($1 \le n \le 5\,000$), the number of towns in Byteotia. The towns are numbered from $1$ to $n$.

The Byteotian road network is then described in $n-1$ lines. Each line contains two integers $a$ and $b$ ($1 ≤ a ≤ b ≤ n$) , separated by a single space, that indicate there is a direct road between the towns $a$ and $b$.

Output Format

The first and only line of the standard output should contain a single integer equal to the number of possible placements of the hotels.

Example

Input

7
1 2
5 7
2 5
2 3
5 6
4 5

Output

5
problem_11292_1.png

The triplets (unordered) of towns where the hotels can be erected are: {1,3,5}, {2,4,6}, {2,4,7}, {2,6,7}, {4,6,7}.

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.