HDU3534 给你一个树让你找出其中最长路径以及个数数

来源:互联网 发布:淘宝买铊的暗语 编辑:程序博客网 时间:2024/06/05 03:12

Description

In the Datastructure class of HEU, the teacher asks one problem: How to find the longestpath(路径) of one treeand the number of such longest path?

Input

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

Output

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

Sample Input

4

1 2 100

2 3 50

2 4 50

4

1 2 100

2 3 50

3 4 50

Sample Output

150 2

200 1

题意:给你一个树让你找出其中最长路径以及个数。

思路:DFS可做

0 0