#P5007. Tree Tumor Set Sum
Tree Tumor Set Sum
Tree Tumor Set Sum
Given a rooted tree with root , we define a tumor set as a set of vertices in which no two vertices have an ancestor–descendant relationship. The tumor index of a tumor set is defined as the sum of the values of all vertices in that set.
The task is to calculate the sum of the tumor indices over all tumor sets of the tree, modulo .
To simplify the problem, an integer is provided which affects the value assigned to each vertex.
- If , then the value of vertex is .
- If , then every vertex has a value of .
Note: The empty set is considered a valid tumor set (its index is ).
inputFormat
The first line contains two integers n
and T
.
Each of the following n-1
lines contains two integers u
and v
, denoting an edge of the tree.
The tree is rooted at vertex 1
.
outputFormat
Print the result modulo 100,000,007
.
sample
1 0
1