树上计数
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
树上计数
题目描述
给定一棵树,标号从 到 ,求无序三元组 的数量满足 且 互不相等。
其中 表示 和 在树上的距离。
输入格式
第一行一个正整数 ,表示点数。
接下去 行,每行两个正整数 ,描述了树上的一条边,连接 。
输出格式
上述三元组数量。
样例
Input 1
7
1 2
5 7
2 5
2 3
5 6
4 5
Output 1
5
不同的三元组有:
{1,3,5},{2,4,6},{2,4,7},{2,6,7},{4,6,7}
提示说明
对于前 的数据,是样例。
对于前 的数据,保证 。
对于前 的数据,保证 。
对于另外 的数据,保证 ,且数据随机。
对于 的数据,保证 。
暴力、部分分训练
- Status
- Done
- Rule
- IOI
- Problem
- 8
- Start at
- 2024-10-6 14:00
- End at
- 2024-10-6 18:00
- Duration
- 4 hour(s)
- Host
- Partic.
- 4