CF23E.Tree
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Recently Bob invented a new game with a tree (we should remind you, that a tree is a connected graph without cycles): he deletes any (possibly, zero) amount of edges of the tree, and counts the product of sizes of the connected components left after the deletion. Your task is to find out the maximum number that Bob can get in his new game for a given tree.
最近,鲍勃发明了一种基于树的新游戏(需要提醒您:树是一种无环的连通图):他删除树中的任意数量(可能为零)的边,并计算删除后剩余各连通分量大小的乘积。您的任务是:对于给定的树,求出鲍勃在该新游戏中所能得到的最大数值。
输入格式
The first input line contains integer number n (1 ≤ n ≤ 700) — amount of vertices in the tree. The following n - 1 lines contain the description of the edges. Each line contains the pair of vertices' indexes, joined by an edge, a__i, b__i (1 ≤ a__i, b__i ≤ n). It's guaranteed that the graph described in the input is a tree.
第一行输入包含一个整数 $ n ( 1 \leq n \leq 700 $)——树中顶点的数量。接下来的 $ n-1 $ 行描述了树的边。每行包含由一条边连接的两个顶点的下标 $ a_i 、 b_i ( 1 \leq a_i, b_i \leq n $)。保证输入所描述的图是一棵树。
输出格式
Output the only number — the maximum product of sizes of the connected components, that Bob can get after deleting some of the tree's edges.
输出唯一的一个数字——鲍勃在删除树中的若干条边后,所能得到的连通块大小乘积的最大值。
输入输出样例
输入#1
5 1 2 2 3 3 4 4 5
输出#1
6
输入#2
8 1 2 1 3 2 4 2 5 3 6 3 7 6 8
输出#2
18
输入#3
3 1 2 1 3
输出#3
3
输入解题思路,AI测评打分。不知道怎么写?