#P4583. [FJOI2015] 世界树
[FJOI2015] 世界树
Description
After Odin slew the giant Ymir, a gigantic ash tree grew from Ymir’s corpse. It became the core of the universe and is called the World Tree. The branches of this colossal tree form the entire world, guarded by mysterious arcane power.
Odin discovered that each node of the World Tree has at most two subtrees. Its arcane power equals the maximum arcane power among its subtrees . If a node has no subtree, its arcane power is ; such nodes are called "sources".
Over the long ages, the World Tree has formed a delicate magical balance: the absolute difference between the arcane powers of the left and right subtrees does not exceed . If a node has only one subtree (say, the left subtree), then the arcane power of the right subtree is treated as .
Now Odin wants to know: in a World Tree with nodes, what is the maximum possible difference between the depths of the deepest and the shallowest two "sources" (i.e., leaf nodes)?
Input Format
The first line contains an integer , the number of test cases.
Each of the next lines contains an integer , the number of nodes in the World Tree.
Output Format
Output lines. Each line contains a single integer: the maximum possible difference between the depths of the deepest and the shallowest "sources".
2
5
12345
1
9
Hint
Constraints: For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号