Isn't the test 2. wrong? For sides 0.5 ,0.5,0.5,0.5 is a square the optimal quadratic shape and the area is 0.5*0.5 that is 0.25 not 1.25.
Quad Area
Yep, that was a typo; sorry about that. It should be fixed now.
it says output the largest possible area. But I don't get it, if there are four sides and they are valid, they can only built a square or a recatengle. And thats all. Where am I wrong?
So I am cheking is it a square or a recatengle and then I cout the area of it. But I get WA...
Problem statement isn't requiring you to check for geometric forms with paralel sides... Right?
"argest possible area of any quadrilateral".
Quadrilateral - how much I know this is a square or a recatengle.
Quadrilateral - how much I know this is a square or a recatengle.
Well, I understood it anyway. I guess Quadrilateral means that it has four angles. :)
I have heard of Green-Reimman's formula for calculating the area of any polygon, but I know only the implementation when I know the coordinates of the dots. Does someone know implementation of Green-Reimmans's formula when we know length of the sides of polygon.
All users used something like Herron's pattern... Calculated S as the half of the sum of all sides and then outputed square root of (S-a)*(S-b)*(S-c)*(S-d)...
But, how come Herron's paterrn can be applied to 4-sided polygon? =S
But, how come Herron's paterrn can be applied to 4-sided polygon? =S
Hm I have google it. Hero's formula in the form we know is special case when triangle is a four sided figure and d = 0. :-D
Interesting. =/
Explanation:
S = ( a + b + c + d ) / 2 = ( a + b + c ) / 2;
Area = Sqrt ( ( S - a ) * ( S - b ) * ( S - c ) * ( S - d ) )
Area = Sqrt ( S * ( S - a ) * ( S - b ) * ( S - c ) )
S = ( a + b + c + d ) / 2 = ( a + b + c ) / 2;
Area = Sqrt ( ( S - a ) * ( S - b ) * ( S - c ) * ( S - d ) )
Area = Sqrt ( S * ( S - a ) * ( S - b ) * ( S - c ) )
I believe the extended heron's formula for the area of quadrilaterals only works for cyclic quadrilaterals.
Yeah, I called my friend who is very good at math and he told me the same thing. ;-)
Well, my friend told me it's good for convex ones, and i trust him :)
That formula is only for cyclic quadrilaterals, not always for convex!
http://en.wikipedia.org/wiki/Brahmagupta's_formula
Basic form
In its basic and easiest-to-remember form, Brahmagupta's formula gives the area of a cyclic quadrilateral whose sides have lengths a, b, c, d as
\sqrt{(s-a)(s-b)(s-c)(s-d)}
where s, the semiperimeter, is
s=\frac{a+b+c+d}{2}.
This formula generalizes Heron's formula for the area of a triangle.
The area of a cyclic quadrilateral is the maximum possible area for any quadrilateral with the given side lengths.
Basic form
In its basic and easiest-to-remember form, Brahmagupta's formula gives the area of a cyclic quadrilateral whose sides have lengths a, b, c, d as
\sqrt{(s-a)(s-b)(s-c)(s-d)}
where s, the semiperimeter, is
s=\frac{a+b+c+d}{2}.
This formula generalizes Heron's formula for the area of a triangle.
The area of a cyclic quadrilateral is the maximum possible area for any quadrilateral with the given side lengths.
What's a cyclic quadraeterial?
i suppose that is the same as convex
A quadrilateral which can be inscribed in a circle. Hence the opposite angles are supplementary.
Well that's the one needed for this task anyway....it has the optimum area
can anyone look at my code and try to find error or does anyone know test examples? My program work on idea of Brahmagupta's formula, but my result for every test case is wrong, but it should work all...
tnx a lot on your help...
I couldn't solve it without you guys...
you're really great.. thank you....
I couldn't solve it without you guys...
you're really great.. thank you....
Can somebody see my code?? I don't know whats wrong :/ Thanks in advance :)