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
mnkp: 2021-07-13 10:05:57

only possible with a specific formula
bad problem...bad problem

dhruv120399: 2020-03-31 10:59:12

brahmgupta's formula is only for cyclic quadrilaterals. The question should mention that.

mrmajumder: 2020-03-21 16:21:38

use fixed with setprecision in cpp

kundan2000: 2019-10-26 23:00:53

take double as data type for c++

sriharsh_11: 2019-01-11 06:53:37

why isn't setprecision working?

begin_143: 2018-09-30 12:07:33

you need to know brahmgupta formula

masterchef2209: 2018-08-13 10:08:07

brahmagupta's formula like heron's formula for scalene triangle but for quadilaterals

AC in 1 go \("_")/

mr_robot_rb01: 2018-07-03 09:21:25

Truncate area to 2 decimal places ...C++

vkash: 2018-02-03 07:41:24

cake Walk:

mpride44: 2017-12-23 20:08:00

simple brahmgupta's formula...AC in 1 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