Putevi
As you are bound to know by now, a tree is a connected graph consisting of N vertices and N−1 edges. Trees also have the property of there being exactly a single unique path between any pair of vertices. You will be given a tree in which every edge is assigned a weight – a non+negative integer. The weight of a path is the product of the weights of all edges on the path. The weight of the tree is the sum of the weights of all paths in the tree. Paths going in opposite directions (A to B and B to A) are considered the same and, when calculating the weight of a tree, are counted only once.Write a program that, given a tree, calculates its weight modulo 1 000 000 007.
Input
3
3 2 100
2 1 100
Output
10200Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.