OpenJudge

J:Tree

总时间限制:
1000ms
内存限制:
65536kB
描述
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
来源
LouTiancheng@POJ

F题:雷达站的坐标需要是double类型而不是int类型
E题:重要逆序对的最后结果请用int型存储
还有其他问题的同学可以在提问栏中提问

全局题号
743
提交次数
7
尝试人数
4
通过人数
0