Factor-Full Tree

시간 제한1초메모리 제한1024 MB

요약
루트가 있는 트리의 각 정점에 10^18 이하의 양의 정수를 붙여, 한 정점이 다른 정점의 조상인 경우에만 그 수가 다른 수를 나누도록 만든다.
난이도

보통10점 중 7점

유형
트리, DFS, 정수론, 그리디
정답자
아직 제출이 없습니다

문제

Aivar is very good at number theory. In fact, it is the only thing he is good at, but this doesn't stop him from achieving great things. However, if Aivar wants to solve any problem in life, he first needs to convert it to number theory.

For example, consider a rooted tree with NN vertices. In order to deal with such structures, Aivar first constructs a divisor labelling of the tree. A divisor labelling is a way to label each vertex vv with a positive integer x_vx\_v so that vv is an ancestor of uu if and only if x_vx\_v divides x_ux\_u.

After constructing such a labelling, Aivar can simply forget about the tree and just think about the list of numbers x_1,x_2,…,x_Nx\_1, x\_2, \dots, x\_N.

You are given a rooted tree with NN vertices, and your task is to find a divisor labelling. The vertices are numbered from 11 to NN, and 11 is the root.

입력

The first line contains an integer NN (1≤N≤601 \leq N \leq 60).

The following N−1N-1 lines each contain two integers uu and vv (1≤u,v≤N1 \leq u, v \leq N, u≠vu \neq v), meaning that an edge goes between vertices uu and vv. These edges will form a tree.

출력

Print one line with NN integers, the numbers x_1,x_2,…x_Nx\_1, x\_2, \dots x\_N. These numbers must satisfy 1≤x_i≤10181 \leq x\_i \leq 10^{18}. It can be shown that under these constraints, an answer always exists.

예제1

  1. 예제 1

    입력
    5
    1 2
    1 3
    3 4
    3 5
    
    예상 출력
    1 2 3 21 33