#abc220f. F - Distance Sums 2
F - Distance Sums 2
Score : points
问题描述
给定一个包含 个顶点的树。顶点编号为 ,第 条边是一条无向边,连接顶点 和 。
对于每个整数 ,计算 的值。
这里, 表示从顶点 到顶点 所需经过的最短边数。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Given is a tree with vertices. The vertices are numbered , and the -th edge is an undirected edge connecting Vertices and .
For each integer , find .
Here, denotes the minimum number of edges that must be traversed to go from Vertex to Vertex .
Constraints
- The given graph is a tree.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines.
The -th line should contain .
Sample Input 1
3
1 2
2 3
Sample Output 1
3
2
3
We have:
,
,
.
Sample Input 2
2
1 2
Sample Output 2
1
1
Sample Input 3
6
1 6
1 5
1 3
1 4
1 2
Sample Output 3
5
9
9
9
9
9
update @ 2024/3/10 09:43:57