当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1741:Tree

题目描述
Give a tree with n vertices,each edge has a length(positive integer less than 1001).
Define dist(u,v)=The min distance between node u and v.
Give an integer k,for every pair (u,v) of vertices is called valid if and only if dist(u,v) not exceed k.
Write a program that will count how many pairs which are valid for a given tree.
输入解释
The input contains several test cases. The first line of each test case contains two integers n, k. (n<=10000) The following n-1 lines each contains three integers u,v,l, which means there is an edge between node u and v of length l.
The last test case is followed by two zeros.
输出解释
For each test case output the answer on a single line.
输入样例
5 4
1 2 3
1 3 1
1 4 2
3 5 1
0 0
输出样例
8

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 LouTiancheng@POJ

源链接: POJ-1741

最后修改于 2020-10-29T06:12:46+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 30000