QUADAREA - Maximal Quadrilateral Area

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.


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

hide comments
2016-12-20 08:52:09
There was a problem when a,b,c,d were float instead of double in c++.Why?
2016-10-27 10:21:54
Java Scanner - 0.42
BufferedReader - 0.31
String Tokenizer - 0.24
Defined Fast I/O - 0.26
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
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)).
2016-07-12 15:49:58
Brahamagupta's Formula!!AC
2016-06-27 14:34:03 suraj
use %Lf for long double and sqrt() for double number
2016-06-26 08:57:31
Buffered Reader + split is faster than Scanner for Time Limit, in java
2016-06-26 08:57:11
Buffered Reader + split is faster than Scanner for Time Limit, in java
2016-05-14 08:05:57
use %Lf for long double
costed me 4 WA
2016-02-06 17:52:35
Bad problem. Formula based. No thinking. Yo BrahmaGupta
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.