401369: GYM100418 I Pair of paths

Memory Limit:64 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Pair of pathstime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output

The kingdom has N castles numbered from 1 to N. The castles are connected with N - 1 roads. The road construction takes a huge amount of money, that's why thrifty inhabitants of the kingdom decided to plan the kingdom in such way that between every pair of castles there is exactly one path. Two brave knights independently start their journeys. Each knight randomly selects two castles where he starts and also finishes his trip. Then he goes through the kingdom by the shortest possible path and writes down all numbers of castles that he visits to his own list. After that they go to the chronicler and give him two lists of the castles which they have visited. And if there is no such castle which was visited by both knights, the chronicler will write to the annals that this pair of journeys was epic. Your goal is to find the number of existing different epic journeys pairs.

Input

At the first line N — number of castles in the kingdom (1 ≤ N ≤ 105). At the next N - 1 lines Ai Bi — roads between castles.

Output

Single line containing the number of existing different epic journeys.

ExamplesInput
6
1 2
1 3
2 4
2 5
3 6
Output
12

加入题单

上一题 下一题 算法标签: