QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 512 MB 満点: 100

#4122. Grafted Tree

統計

Alice has designed a tree structure with $N$ nodes (including the root), labeled $1$ to $N$, connected by $N-1$ edges. Later, Bob added $K$ edges that were not previously present (meaning there are no self-loops, and no multiple edges are created) to the tree, and called the resulting graph a "$K$-grafted tree".

Alice wants to color each node of the grafted tree, allowing the use of exactly $N$ colors, labeled $1$ to $N$. Alice requires that any two adjacent nodes must be painted with different colors.

Assuming the number of nodes painted with color $i$ is $t_i$, Bob provides the following evaluation score:

$$score = \frac{t_1 + \frac{t_2}{2} + \frac{t_3}{3} + \dots + \frac{t_N}{N}}{1 + P(t_1 + 2t_2 + 3t_3 + \dots + Nt_N)}$$

where $P$ is a non-negative constant. Now, Alice wants to find a coloring scheme that maximizes the score provided by Bob. Can you help her?

Input

The first line contains two integers $N$ and $K$, as described above. The next $N+K$ lines each contain two integers $u$ and $v$, describing the $N+K-1$ edges. It is guaranteed that there are no self-loops and no multiple edges. The last line contains a non-negative float $P$.

Output

Output the maximum possible score, rounded to three decimal places.

Constraints

For 50% of the data, $K = 0$, $1 \le N \le 100000$, $0 \le P < 10$. Among these, 25% of the data has $P = 0$. For the other 50% of the data, $K \le 2$, $1 \le N \le 20000$, $0 \le P < 10$. Among these, 25% of the data has $P = 0$.

Examples

Input 1

9 0
1 2
1 3
1 4
1 5
2 6
2 7
2 8
2 9
2.5

Output 1

0.253

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.