문제
You are given an undirected tree with each of its node assigned a magic . 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 ≤ ), the number of nodes in the tree. Each of the following N - 1 lines contains two integers, and (1 ≤ , ≤ N), the labels of nodes connected with an edge. The i-th of the following N lines contains the integer (1 ≤ ≤ ), magic of the i-th 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 .
채점
In test cases worth 24 points total, it will hold N ≤ 1 000. In test cases worth 36 additional points total, there will not be a node that is connected to more than 2 other nodes.
예제 입력 1
2
1 2
3
4
예제 출력 1
3/1
예제 입력 2
5
1 2
2 4
1 3
5 2
2
1
1
1
3
예제 출력 2
1/2
코드를 제출하려면 로그인이 필요합니다.
로그인