Technocup 2019 - Elimination Round 4
D
Minimum Diameter Tree
Codeforces
1700
原题
← CE →
翻译中…

You are given a tree (an undirected connected graph without cycles) and an integer $s$.

翻译中…

Vanya wants to put weights on all edges of the tree so that all weights are non-negative real numbers and their sum is $s$. At the same time, he wants to make the diameter of the tree as small as possible.

翻译中…

Let's define the diameter of a weighed tree as the maximum sum of the weights of the edges lying on the path between two some vertices of the tree. In other words, the diameter of a weighed tree is the length of the longest simple path in the tree, where length of a path is equal to the sum of weights over all edges in the path.

翻译中…

Find the minimum possible diameter that Vanya can get.

翻译中…

Input

翻译中…

The first line contains two integer numbers $n$ and $s$ ($2 \leq n \leq 10^5$, $1 \leq s \leq 10^9$) — the number of vertices in the tree and the sum of edge weights.

翻译中…

Each of the following $n−1$ lines contains two space-separated integer numbers $a_i$ and $b_i$ ($1 \leq a_i, b_i \leq n$, $a_i \neq b_i$) — the indexes of vertices connected by an edge. The edges are undirected.

翻译中…

It is guaranteed that the given edges form a tree.

翻译中…

Output

翻译中…

Print the minimum diameter of the tree that Vanya can get by placing some non-negative real weights on its edges with the sum equal to $s$.

翻译中…

Your answer will be considered correct if its absolute or relative error does not exceed $10^{-6}$.

翻译中…

Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is considered correct if $\frac {|a-b|} {max(1, b)} \leq 10^{-6}$.

翻译中…

Note

翻译中…

In the first example it is necessary to put weights like this:

翻译中…

image

翻译中…

It is easy to see that the diameter of this tree is $2$. It can be proved that it is the minimum possible diameter.

翻译中…

In the second example it is necessary to put weights like this:

翻译中…

image

翻译中…

样例

Input #1
4 3
1 2
1 3
1 4
Output #1
2.000000000000000000
InputCopy OutputCopy
Input #2
6 1
2 1
2 3
2 5
5 4
5 6
Output #2
0.500000000000000000
InputCopy OutputCopy
Input #3
5 5
1 2
2 3
3 4
3 5
Output #3
3.333333333333333333
InputCopy OutputCopy
题目信息
题号
1085D
时间限制
1 s
内存限制
256 MB
标签
构造
模拟
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。