Gifts
InterviewTime limit2sMemory limit128 MB
Find the maximum cube side length A so that N cubes of size A can fit inside an L×W×H box, using binary search on A.
- Level
Medium4 of 10
- Topics
- Binary search, Math
- Solved
- No attempts yet
Problem
Minsik has N small boxes of the same size to give as gifts. Every small box is a cube with side length A, so its size is A × A × A.
He wants to put all of these small boxes into a rectangular box of size L × W × H. Every small box must be entirely inside the large box, and each edge of every small box must be parallel to an edge of the large box.
Given N, L, W, and H, find the maximum possible value of A.
Input
The first line contains four integers N, L, W, and H.
Output
Print the maximum possible value of A. An absolute or relative error of at most 10^-9 is accepted.
Constraints
1 ≤ N ≤ 1,000,000,0001 ≤ L, W, H ≤ 1,000,000,000