Under construction

Still being built. Things may change

Balance

Time limit1sMemory limit1024 MB

Summary
Given a vertex budget V, find the maximum possible height of an AVL tree built with at most V vertices.
Level

Medium4 of 10

Topics
Dynamic programming, Tree, Binary search, Math
Solved
No attempts yet

Problem

AVL Tree, a kind of binary search tree, keeps itself balanced using a property called the height balance property.

Every binary search tree that satisfies the height balance property is an AVL Tree.

For every internal vertex vv of a tree TT, if the heights of the left subtree and right subtree of vv differ by at most 1, then TT is said to satisfy the height balance property.

In the figure above, the tree on the left is an AVL Tree because every internal vertex has a left subtree and right subtree of equal height.

The tree in the middle is an AVL Tree because vertices 5, 6, and 8 have left and right subtrees whose heights differ by 1, and all other vertices have a difference of 0.

The tree on the right is not an AVL Tree because vertex 8 has left and right subtrees whose heights differ by 2.

Given a positive integer VV, write a program that prints the maximum height of an AVL Tree that can be built using at most VV vertices.

Input

The first line gives the number of test cases TT.

From the second line, TT lines follow, each giving the number of vertices VV.

Output

Print the answer over TT lines.

For each test case, print the maximum height of an AVL Tree that can be built with at most VV vertices.

Constraints

  • 1≤T≤1 0001 \leq T \leq 1\,000
  • 1≤V≤1 000 000 0001 \leq V \leq 1\,000\,000\,000

Examples1

  1. Example 1

    Input
    5
    1
    2
    5
    10
    1000000000
    
    Expected output
    1
    2
    3
    4
    42