A Tough Question
All submissions for this problem are available.
Chef recently interviewed at a company X. He could not answer a question on connected components. Chef is restless and is wondering how to solve this problem.
Problem states that given a tree delete any (possibly zero) number of edges from the tree and find the product of sizes of the connected components left after deletion. We need to find the maximum possible value of this product.
This question is too tough for Chef to answer. Can you help Chef in answering this tough question?
First line contains a single integer N denoting the no of vertices of tree. Next N-1 lines contain two integers a and b denoting an edge between a and b.
Print a single integer denoting the maximum possible value of product of connected components.
- 1 <= N <= 100
Input: 5 1 2 2 3 3 4 4 5 Output: 6
Input: 8 1 2 1 3 2 4 2 5 3 6 3 7 6 8 Output: 18
Input: 3 1 2 1 3 Output: 3
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS|
Fetching successful submissions