Making a Box
Time limit1sMemory limit128 MB
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 . The box must have a square base and an open top. It is made in two steps:
- Cut a square piece of side from each of the four corners of the panel.
- Fold the four remaining rectangular flaps straight up to form the walls.
The resulting box has a square base of side and height , so its volume is .
Find the height that maximizes the volume .
Input
The first line contains the number of test cases (). Each of the next lines contains one real number (), the side length of a panel.
Output
For each test case, print the value of that maximizes the volume, rounded to digits after the decimal point, one per line.
Hint
If you still have time after solving this, please help Kkung find a girlfriend too.