Given a general tree, being its size (its number of elements), and being its height. The quotient is a measure of how much “flattened” is the tree.
(To see some instances, consult the pdf or ps version of this wording.)
Write a program that reads the shape of various general trees, and for each one prints the maximal quotient of all its subtrees.
Input starts with , the number of trees that must be treated The description of the trees follow as is explained at the exercise REREG, with two exceptions: The values are not given, because the content of the nodes here is not important. The number of nodes is neither given, because you do not need to store the trees in any vector to solve this exercise.
Your program must print with three figures the maximal quotient of the subtrees of each given tree.
Input
3 3 2 0 1 1 0 0 4 0 0 0 0 2 1 0 0 2 0 0
Output
2.500 1.333 1.500