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.

Input

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.

Output

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.

Example

Input:
2
1 2 1 2
0.5 0.5 0.5 0.5

Output:
2.00
0.25

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


hide comments
davidgalehouse: 2016-09-21 06:57:42

Can someone teach me why we can create (I mean assume one exists) a cyclic quadrilateral out of any set of sides?

Last edit: 2016-09-21 06:58:01
pwnclub: 2016-08-26 05:18:17

If you're using C++ and cout is giving you WA, try setting the output to two decimal places (fixed and setprecision(2)).

baadshah_: 2016-07-12 15:49:58

Brahamagupta's Formula!!AC

suraj: 2016-06-27 14:34:03

use %Lf for long double and sqrt() for double number

aryanagal: 2016-06-26 08:57:31

Buffered Reader + split is faster than Scanner for Time Limit, in java

aryanagal: 2016-06-26 08:57:11

Buffered Reader + split is faster than Scanner for Time Limit, in java

g4mewarrior: 2016-05-14 08:05:57

use %Lf for long double
costed me 4 WA

sarthak_8: 2016-02-06 17:52:35

Bad problem. Formula based. No thinking. Yo BrahmaGupta

iharsh234: 2015-12-27 11:34:15

move to tutorials

mdsharique: 2015-12-06 18:47:52

AC in one go......


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