RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00406

Mag

Unrated 레이팅 미적용
난이도
4s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

4 \(s / 256\) \(MB / 120\) points

You are given an undirected tree with each of its node assigned a magic \(X\)

\(i\)

.
1
The magic of a path is defined as the product of the magic of the nodes on that path divided
2
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 \cdot 5 / 2\)).

In the given tree, find the path with the minimal magic and output the magic of that path.

제약

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.

입력 형식

The first line of input contains the integer \(N\)

(1 ≤ \(N\)

≤ 10 {6}{ }), the number of nodes in the tree.
Each of the following \(N - 1\) lines contains two integers, \(A\)

\(i\)

and \(B\)

\(i\)

(1 ≤ \(A\)

\(i\)

, \(B\)

\(i\)

\(N\)

), the labels of
nodes connected with an edge.
The \(i\)

{th}{ } of the following \(N\)

lines contains the integer \(X\)

\(i\)

( 1

\(X\)

\(i\)

10 {9}{ }) ,

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 10 {18}{ }.

예제 1
입력
2
1 2
3
4
5
1 2
2 4
1 3
5 2
2
1
1
1
1 ​An ​undirected tree is a connected graph that consists of ​N
​
 nodes and ​N
​
 - 1 undirected
edges.
2 ​A ​path​ in a ​graph​ is a finite ​sequence​ of ​edges​ which connect a sequence of ​vertices
which   are all distinct from one another



4 s / 256 MB / 120 points

3
출력
output
3/1
1/2
설명

Clarification of the first test case:
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.

Clarification of the second test case:
The path that consists of nodes with labels 2 and 4 is of magic (1⋅1) / 2 = 1 / 2.
That is also the path with the minimal possible magic.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2016/2017 Contest 1

평가 및 의견

Mag

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Mag

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8