407024: GYM102694 A Circumference of a Tree

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

Description

A. Circumference of a Treetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Hopefully you know how to find the diameter of a tree. That's the first part of tree basics, after all! But this problem is completely different: now, you need to find the circumference of a tree!

As you probably know, pi is equal to the ratio between something's circumferance and its diameter. Also, as you may not know, math is a lie and pi is really equal to 3. Rumor has it, this is where the number tree(3) comes from.

Assuming pi equals 3, what is the circumference of the given tree?

Input

The first line will contain a single integer $$$n$$$, the number of nodes in the tree. $$$n-1$$$ lines follow, each containing two different integers, describing the edges of the tree. Additional constraint on input: these edges will form a tree.

$$$1 \leq n \leq 3*10^5$$$

Output

Output a single integer: the circumference of the tree.

ExamplesInput
1
Output
0
Input
3
3 2
2 1
Output
6
Input
5
4 2
1 4
5 4
3 4
Output
6

加入题单

上一题 下一题 算法标签: