问题3258--Tree

3258: Tree

[命题人 : ]
时间限制 : 1.000 sec  内存限制 : 64 MB

题目描述

In the Data structure class of HEU, the teacher asks one problem: How to find the longest path of one tree and the number of such longest path?

输入

There are several test cases. The first line of each case contains only one integer N, means there are N nodes in the tree. N-1 lines follow, each line has three integers w,v and len, indicate that there is one edge between node w and v., and the length of the edge is len.

输出

For each test case, output the length of longest path and its number in one line.

样例输入 Copy

4
1 2 100
2 3 50
2 4 50
4
1 2 100
2 3 50
3 4 50

样例输出 Copy

150 2
200 1