Submit | All submissions | Best solutions | Back to list |
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
|
||||||||||
2015-12-27 11:34:15
move to tutorials |
||||||||||
2015-12-06 18:47:52
AC in one go...... |
||||||||||
2015-10-22 14:11:51 Divyansh Shukla
@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 |
||||||||||
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 |
||||||||||
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. |
||||||||||
2015-09-23 09:08:09
formula based...!!! |
||||||||||
2015-08-13 21:13:44 Mohd Ausaf Jafri
move it to tutorial ;) |
||||||||||
2015-07-12 12:42:48 NEO
for a given perimeter or length ... circle has the maximum area .... so whenever asked for the maximum area ... consider it as a circle.. |
||||||||||
2015-07-11 18:53:05
pure maths ac in .0.00s s=a+b+c+d/2; area=sqrt(s-a*s-b*s-c*s-d) ; yoo brahmagupta |
||||||||||
2015-07-11 18:53:03
pure maths ac in .0.00s s=a+b+c+d/2; area=sqrt(s-a*s-b*s-c*s-d) ; yoo brahmagupta |