#P1411. Maximum Score by Edge Removal in a Tree

    ID: 14697 Type: Default 1000ms 256MiB

Maximum Score by Edge Removal in a Tree

Maximum Score by Edge Removal in a Tree

Given a tree with (n) nodes, you are allowed to remove any number (possibly 0) of edges from the tree. Removing edges splits the tree into a forest (a collection of connected components). For each connected component, let its score be its size (i.e. the number of nodes in that component). The overall score (L) is defined as the product of the scores of all connected components, i.e., (L=\prod_{i=1}^{k} s_i) where (s_i) is the size of the (i)th component. Your task is to compute the maximum possible value of (L) obtainable by removing a subset of edges from the given tree.

It is guaranteed that the tree is undirected and given by (n-1) edges.

Note: The answer is the exact product (without taking any modulo).

inputFormat

The first line contains a single integer \(n\) (the number of nodes). The next \(n-1\) lines each contain two integers \(u\) and \(v\) (1-indexed) that represent an edge connecting nodes \(u\) and \(v\).

outputFormat

Output a single integer, which is the maximum score \(L\) obtainable.

sample

3
1 2
2 3
3