← Back to topics
Topic

Quad Area

m
msantl
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.
n
neal_wu
Yep, that was a typo; sorry about that. It should be fixed now.
D
Daniel93
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?
D
Daniel93
So I am cheking is it a square or a recatengle and then I cout the area of it. But I get WA...
i
iggy91
Problem statement isn't requiring you to check for geometric forms with paralel sides... Right?
D
Daniel93
"argest possible area of any quadrilateral".
Quadrilateral - how much I know this is a square or a recatengle.
D
Daniel93
Well, I understood it anyway. I guess Quadrilateral means that it has four angles. :)
A
Al3kSaNdaR
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.
i
iggy91
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
A
Al3kSaNdaR
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
i
iggy91
Interesting. =/
A
Al3kSaNdaR
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 ) )
f
frank44
I believe the extended heron's formula for the area of quadrilaterals only works for cyclic quadrilaterals.
A
Al3kSaNdaR
Yeah, I called my friend who is very good at math and he told me the same thing. ;-)
t
turgond
Well, my friend told me it's good for convex ones, and i trust him :)
m
mario93
That formula is only for cyclic quadrilaterals, not always for convex!
n
nemanja1990
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.
t
tgudlek
What's a cyclic quadraeterial?
n
nemanja1990
i suppose that is the same as convex
f
frank44
A quadrilateral which can be inscribed in a circle. Hence the opposite angles are supplementary.
t
turgond
Well that's the one needed for this task anyway....it has the optimum area
n
nenad1001
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...
n
nenad1001
tnx a lot on your help...
I couldn't solve it without you guys...
you're really great.. thank you....
V
Vladimir98
Can somebody see my code?? I don't know whats wrong :/ Thanks in advance :)