2017-5-14 湘潭市赛 Highway 先获得直径S,T。则一开始S,T相连,然后其他的点如果离S更远那么连在S,否则T;

发布时间:2017-5-17 6:58:35编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"2017-5-14 湘潭市赛 Highway 先获得直径S,T。则一开始S,T相连,然后其他的点如果离S更远那么连在S,否则T; ",主要涉及到2017-5-14 湘潭市赛 Highway 先获得直径S,T。则一开始S,T相连,然后其他的点如果离S更远那么连在S,否则T; 方面的内容,对于2017-5-14 湘潭市赛 Highway 先获得直径S,T。则一开始S,T相连,然后其他的点如果离S更远那么连在S,否则T; 感兴趣的同学可以参考一下。

HighwayAccepted : 33           Submit : 137Time Limit : 4000 MS           Memory Limit : 65536 KBHighwayIn ICPCCamp there were n towns conveniently numbered with 1,2,…,n connected with (n−1) roads. The i-th road connecting towns ai and bi has length ci. It is guaranteed that any two cities reach each other using only roads.Bobo would like to build (n−1) highways so that any two towns reach each using only highways. Building a highway between towns x and y costs him δ(x,y) cents, where δ(x,y) is the length of the shortest path between towns x and y using roads.As Bobo is rich, he would like to find the most expensive way to build the (n−1) highways.InputThe input contains zero or more test cases and is terminated by end-of-file. For each test case:The first line contains an integer n. The i-th of the following (n−1) lines contains three integers ai, bi and ci.    1≤n≤105    1≤ai,bi≤n    1≤ci≤108    The number of test cases does not exceed 10.OutputFor each test case, output an integer which denotes the result.Sample Input51 2 21 3 12 4 23 5 151 2 21 4 13 4 14 5 2


上一篇:java用while循环设计轮询线程的性能问题
下一篇:Excel中值得收藏的12个函数公式

相关文章

相关评论

本站评论功能暂时取消,后续此功能例行通知。

一、不得利用本站危害国家安全、泄露国家秘密,不得侵犯国家社会集体的和公民的合法权益,不得利用本站制作、复制和传播不法有害信息!

二、互相尊重,对自己的言论和行为负责。

好贷网好贷款