问题描述:
ACM 关于 树和子数的概念
B.Tree
Dear contestant,I bet you must know what a tree represent.In data structure,we learn
a tree is a graph in which every two nodes have and only have one path.
Here comes an easy problem,given a tree with nodes have its weight,the weight of a
tree is the sum of the weight of all nodes on it.Now we have a chance to divide the
tree into two subtrees,and we want to know the minimum difference between the two
subtrees‟weight.
Input
The first line contains a single integer T,indicating the number of test cases.
Each test case begins with one integer N (2
B.Tree
Dear contestant,I bet you must know what a tree represent.In data structure,we learn
a tree is a graph in which every two nodes have and only have one path.
Here comes an easy problem,given a tree with nodes have its weight,the weight of a
tree is the sum of the weight of all nodes on it.Now we have a chance to divide the
tree into two subtrees,and we want to know the minimum difference between the two
subtrees‟weight.
Input
The first line contains a single integer T,indicating the number of test cases.
Each test case begins with one integer N (2
问题解答:
我来补答展开全文阅读