TRICENTR - Triangle From Centroid

Given the length of side a of a triangle and the distances from the centroid (the point of concurrence of the medians - red in the picture) to all sides: a, b and c, calculate this triangle's area and the distance (blue line) from the orthocenter (the point of concurrence of the heights - green in the picture) to the centroid.

Input

In the first line integer n - the number of test cases (equal to about 1000). The next n lines - 4 floating point values: the length of side a, and distances from the centroid to sides a, b and c.

Output

n lines consisting of 2 floating point values with 3 digits after the decimal point: the area of the triangle and the distance from the orthocenter to centroid.

Example

Input:
2
3.0 0.8660254038 0.8660254038 0.8660254038
657.8256599140 151.6154399062 213.5392629932 139.4878846649

Output:
3.897 0.000
149604.790 150.275

Added by:Patryk Pomykalski
Date:2004-05-22
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS PERL6 VB.NET

hide comments
2013-02-15 12:46:09 Mike Rush
Who can help me?
2013-02-15 12:45:43 Mike Rush
It's too hard
2012-10-28 08:16:57 Lloyd_feb
can some one help me.
I am getting WA for this prob. But on simulating the test case given here my output shows the correct answer.
What could be the problem? Iam printing the o/p correctly
2012-09-22 04:18:13 P Venkata sri harsha
can anyone give more test cases i am struck with WA
2012-07-24 00:02:14 The Vagabond
this question tests only mathematical skill.....anybody can search for formulas relating area of triangle in terms of given parameter :( :(
However,Second part of the problem seem quite interesting.:)

Last edit: 2012-07-24 00:19:20
2012-07-06 10:26:38 saket diwakar
@all, no the given output is correct..my AC solution gives the same...
2011-10-18 17:11:27 つ ◕_◕ ༽つ GIFF AC
yeah case 2 area is wrong, should be .797
Disregard this, the test case is correct

Last edit: 2011-10-20 04:50:44
2011-07-04 11:31:15 bashrc is back
@prab are you printing new line after every case?I got 3 WA's coz of dat
2011-03-12 09:04:24 __Pra
well my formula is correct but i'm getting different area ..even from scientif calc for case 2!!
2010-04-25 20:22:25 Lewin Gan
Of course this can be done in java, it's just plugging numbers into a formula: O(1) time
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.