Janitor Troubles

Interview

Time limit1sMemory limit512 MB

Summary
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 s1,s2,s3s_1, s_2, s_3 and s4s_4, 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 s1,s2,s3s_1, s_2, s_3, and s4s_4.

It is guaranteed that 2si<∑j=14sj2s_i < \sum_{j=1}^{4} s_j, for all ii, and that 1≤si≤10001 \le s_i \le 1000.

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 10−610^{-6}.

Examples3

  1. Example 1

    Input
    3 3 3 3
    
    Expected output
    9
    
  2. Example 2

    Input
    1 2 1 1
    
    Expected output
    1.299038105676658
    
  3. Example 3

    Input
    2 2 1 4
    
    Expected output
    3.307189138830738