Give a tree with nnn vertices,each edge has a length. Define dist(u,v)=The min distance between node uuu and vvv. Give an integer kkk,for every pair (u,v) of vertices is called valid if and only if dist(u,v) not exceed kkk. Write a program that will count how many pairs which are valid for a given tree. 1≤N≤1041leq Nleq 10^41≤N≤104, 1≤K≤5×1061leq Kleq 5×10^61≤K≤5×106, 1≤l≤1031leq lleq 10^31≤l≤103
Give a tree with nnn vertices,each edge has a length(positive integer less than 1000). Define dist(u,v)=The min distance between node uuu and vvv. Give an integer kkk,for every pair (u,v) of vertices is called valid if and only if dist(u,v) not exceed kkk. Write a program that will count how many pairs which are valid for a given tree. 1≤N≤1041leq Nleq 10^41≤N≤104, 1≤K≤5×1061leq Kleq 5×10^61≤K≤5×106, 1≤l≤1031leq lleq 10^31≤l≤103
(图片来源网络,侵删)