Janitor Troubles
InterviewTime limit1sMemory limit512 MB
Given four side lengths that can form a quadrilateral, output its maximum possible area, given by Brahmagupta's formula with the semiperimeter.
- Level
Medium4 of 10
- Topics
- Math, Geometry, Implementation
- Solved
- No attempts yet
Problem
While working a night shift at the university as a janitor, you absent-mindedly erase a blackboard covered with equations, only to realize afterwards that these were no ordinary equations! They were the notes of the venerable Professor E. I. N. Stein who earlier in the day solved the elusive maximum quadrilateral problem! Quick, you have to redo his work so no one noticed what happened.
The maximum quadrilateral problem is quite easy to state: given four side lengths and , find the maximum area of any quadrilateral that can be constructed using these lengths. A quadrilateral is a polygon with four vertices.
Input
The input consists of a single line with four positive integers, the four side lengths , and .
It is guaranteed that , for all , and that .
Output
Output a single floating point number, the maximal area as described above. Your answer must be accurate to an absolute or relative error of at most .