#P7159. 「dWoi R1」Sweet Fruit Chocolate
「dWoi R1」Sweet Fruit Chocolate
Description
Tojo makes the chocolate she wants to pour into a “chocolate fountain tree”. The chocolate fountain tree is a tree with nodes. Each node has a Sisyphus fruit. For each node , you have two choices: you can place fruits at node , or place no fruit at all. Then, Tojo will pour chocolate syrup from the root downward. The nutrition value that node brings to Saihara is the number of Sisyphus fruits placed in and its subtree. Tojo wants to know, among all fruit-placement plans, what is the total sum of Saihara’s nutrition values. Output the answer modulo .
The root of the tree is node .
Input Format
The first line contains a positive integer .
The second line contains positive integers .
In the next lines, each line contains two positive integers , indicating that there is an edge in the tree.
Output Format
One line containing an integer representing the answer.
3
1 1 2
1 2
2 3
36
Hint
Sample 1 Explanation
Use to represent the selected state.
- contributes .
- contributes .
- contributes .
- contributes .
- contributes .
- contributes .
- contributes .
- contributes .
Constraints
For of the testdata, .
For another of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号