Making a Box

Time limit1sMemory limit128 MB

Summary
Given a square panel of side a, find the corner cut b in (0, a/2) that maximizes the open box volume b(a-2b)^2.
Level

Medium4 of 10

Topics
Math, Binary search
Solved
No attempts yet

Problem

Kkung wants to make a gift box for his future girlfriend out of a square panel of size a×aa \times a. The box must have a square base and an open top. It is made in two steps:

  1. Cut a square piece of side bb from each of the four corners of the panel.
  2. Fold the four remaining rectangular flaps straight up to form the walls.

The resulting box has a square base of side a−2ba - 2b and height bb, so its volume is V(b)=b (a−2b)2V(b) = b\,(a - 2b)^2.

Find the height bb that maximizes the volume V(b)V(b).

Input

The first line contains the number of test cases nn (1≤n≤101 \le n \le 10). Each of the next nn lines contains one real number aa (1≤a≤10241 \le a \le 1024), the side length of a panel.

Output

For each test case, print the value of bb that maximizes the volume, rounded to 1010 digits after the decimal point, one per line.

Hint

If you still have time after solving this, please help Kkung find a girlfriend too.

Examples2

  1. Example 1

    Input
    1
    34.0
    
    Expected output
    5.6666666667
    
  2. Example 2

    Input
    1
    6.0
    
    Expected output
    1.0000000000