#P1411. 树

    ID: 404 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划,dp树形结构福建省历届夏令营

Description

He deletes any number (possibly 00) of edges from the tree and computes the product of the sizes of all connected components after the deletions. L scores that many points. Your task is, for a given tree, to find the maximum score L can obtain.

Input Format

The first line contains an integer nn, the number of nodes in the tree.

The next (n1)(n-1) lines each contain two integers u,vu, v, indicating that there is an edge connecting uu and vv.

Output Format

Output a single integer, the maximum score L can obtain.

5
1 2
2 3
3 4
4 5

6

8
1 2
1 3
2 4
2 5
3 6
3 7
6 8

18

3
1 2
1 3 

3 

Hint

Constraints

  • For 10%10\% of the testdata, n5n \leq 5.
  • For 30%30\% of the testdata, n100n \leq 100.
  • For another 30%30\% of the testdata, the given tree is a path.
  • For 100%100\% of the testdata, 1n7001 \leq n \leq 700, 1u,vn1 \leq u, v \leq n.

Translated by ChatGPT 5