QUADAREA - Maximal Quadrilateral Area

no tags 

You are trying to build a house, but unfortunately you currently have only four available walls with side lengths a, b, c, and d. You want your house to be as big as possible, so you would like to know the largest possible area of any quadrilateral you can construct with these four side lengths.


The first line contains the integer T (1 ≤ T ≤ 2,000), the number of tests. Each test contains a single line with four real numbers: a, b, c, and d (0 < a, b, c, d < 1,000). Note that it will always be possible to form a valid quadrilateral with these lengths; that is, the sum of any three side lengths will be strictly larger than the other one.


For each test case, print a single line containing the largest possible area. Your output will be accepted if it is within 0.01 of the official answer.


1 2 1 2
0.5 0.5 0.5 0.5


For the first test case, it is optimal to construct a rectangle, and for the second, a square is optimal.

hide comments
legrand: 2012-02-28 13:16:23


Last edit: 2012-03-21 16:07:29
cannot_in2_coding: 2011-12-25 20:37:17

wolframalpha FTW

nilaysahu: 2011-10-10 13:39:20

Thanks ~the champ~

Puneet Jain: 2011-07-23 18:45:40

Last edit: 2011-07-23 18:46:15
The Champ: 2010-10-12 21:24:21

for C++ coders, use double instead of float.. i got AC doing that

Last edit: 2010-10-12 21:24:55
Saransh Bansal: 2010-07-21 12:39:07

please see that java shud not be giving TLE cause of stupid I/O optimisations.

Added by:Neal Wu
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO