#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 +1+1. If a node has no subtree, its arcane power is 11; 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 11. If a node has only one subtree (say, the left subtree), then the arcane power of the right subtree is treated as 00.

Now Odin wants to know: in a World Tree with nn 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 TT, the number of test cases.

Each of the next TT lines contains an integer nn, the number of nodes in the World Tree.

Output Format

Output TT 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 100%100\% of the testdata, 1n10100001 \leq n \leq 10^{10000}, T50T \leq 50.

Translated by ChatGPT 5