# Tree chain problem 用C语言怎么进行计算？

Problem Description
Coco has a tree, whose vertices are conveniently labeled by 1,2,…,n.
There are m chain on the tree, Each chain has a certain weight. Coco would like to pick out some chains any two of which do not share common vertices.
Find out the maximum sum of the weight Coco can pick

Input
The input consists of several test cases. The first line of input gives the number of test cases T (T<=10).
For each tests:
First line two positive integers n, m.(1<=n,m<=100000)
The following (n - 1) lines contain 2 integers ai bi denoting an edge between vertices ai and bi (1≤ai,bi≤n),
Next m lines each three numbers u, v and val（1≤u，v≤n，0<val<1000）, represent the two end points and the weight of a tree chain.

Output
For each tests:
A single integer, the maximum number of paths.

Sample Input
1
7 3
1 2
1 3
2 4
2 5
3 6
3 7
2 3 4
4 5 3
6 7 3

Sample Output
6

• 写回答

#### 2条回答默认 最新

• threenewbee 2019-03-28 10:47
关注
本回答被题主选为最佳回答 , 对您是否有帮助呢?
评论

#### 悬赏问题

• ¥15 使用深度优先搜索所有可能路径
• ¥20 Ant Design of Vue 的表格使用，根据当前代码，实现以下功能
• ¥25 Error: python: can't open file [Errno 2] No such file or directory，如何解决？（相关搜索：python文件）
• ¥15 C#中模版应用的问题
• ¥15 Lambda expressions are allowed only at source level 1.8 or above报错，有没有解决办法
• ¥15 请问有没有哪种软可实现图片里不同背景部分实现剪切分离
• ¥15 codesys 使用问题
• ¥15 Postman一直转圈进不去咋办？
• ¥15 Kb4103712更新无法完成
• ¥60 animate html5如何制作涂鸦画板？实现画笔、擦除和清屏功能