|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|4 초||256 MB||77||16||14||22.581%|
You are given an undirected tree with each of its node assigned a magic Xi.
The magic of a path is defined as the product of the magic of the nodes on that path divided by the number of the nodes on the path. For example, the magic of a path that consists of nodes with magic 3 and 5 is 7.5 (3⋅5 / 2).
In the given tree, find the path with the minimal magic and output the magic of that path.
The first line of input contains the integer N (1 ≤ N ≤ 106), the number of nodes in the tree.
Each of the following N - 1 lines contains two integers, Ai and Bi (1 ≤ Ai, Bi ≤ N), the labels of nodes connected with an edge.
The ith of the following N lines contains the integer Xi (1 ≤ Xi ≤ 109 ), magic of the ith node.
Output the magic of the path with minimal magic in the form of a completely reduced fraction P/Q (P and Q are relatively prime integers).
In all test cases, it will hold that the required P and Q are smaller than 1018.
2 1 2 3 4
5 1 2 2 4 1 3 5 2 2 1 1 1 3
Notice that the path may begin and end in the same node. The path with the minimal magic consists of the node with magic 3, so the entire path’s magic is 3 / 1.