#abc312g. G - Avoid Straight Line
G - Avoid Straight Line
Score : points
问题描述
给定一棵包含 个顶点的树。顶点编号从 到 ,第 条边连接顶点 和顶点 。
求满足以下条件的整数元组 的数量:
- ;
- 所给定的树中不存在一条简单路径,该路径包含了顶点 、 和 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a tree with vertices. The vertices are numbered from through , and the -th edge connects vertex and vertex .
Find the number of tuples of integers such that:
- ; and
- the given tree does not contain a simple path that contains all of vertices , , and .
Constraints
- The given graph is a tree.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
5
1 2
2 3
2 4
1 5
Sample Output 1
2
Two tuples satisfy the conditions: .
Sample Input 2
6
1 2
2 3
3 4
4 5
5 6
Sample Output 2
0
Sample Input 3
12
1 6
3 4
10 4
5 9
3 1
2 3
7 2
2 12
1 5
6 8
4 11
Sample Output 3
91
update @ 2024/3/10 08:54:15