You are given a tree, that is, an undirected, connected graph with no cycles. Can you count how many (non-empty) connected subgraphs it contains?
Input consists of several trees, each one with the number of vertices , followed by its edges. You can assume , that vertices are numbered between 0 and , and that the given edges indeed form a tree.
For every given tree, print its number of connected subgraphs. As this number may be large, make the computations modulo .
Author: Edgar Moreno
Generation: 2026-01-25T11:52:55.342Z
© Jutge.org, 2006–2026.
https://jutge.org