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.
hide comments
iharsh234:
2015-12-27 11:34:15
move to tutorials |
|
mdsharique:
2015-12-06 18:47:52
AC in one go...... |
|
Divyansh Shukla:
2015-10-22 14:11:51
@gohanssj9 This problem uses Bretschneider's formula, using which we can conclude that to maximise the area, the quadrilateral must be cyclic, i.e. sum of two opposite angles must be 180 |
|
praveenpourush:
2015-10-11 08:15:30
@gohanssj9 Actually when its asked that the quad area must be maximum so it indirectly means that the quad is CYCLIC! Last edit: 2015-10-11 08:18:18 |
|
alexbandeira:
2015-09-26 18:17:57
Tnk's The Champ! In C does not work with float. Use double with "%lf " at the entrance and "% .2lf " in output. |
|
sonupmandal:
2015-09-23 09:08:09
formula based...!!! |
|
Mohd Ausaf Jafri:
2015-08-13 21:13:44
move it to tutorial ;) |
|
NEO:
2015-07-12 12:42:48
for a given perimeter or length ... circle has the maximum area .... so whenever asked for the maximum area ... consider it as a circle..
|
|
karthik1997:
2015-07-11 18:53:05
pure maths
|
|
karthik1997:
2015-07-11 18:53:03
pure maths
|
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 |