## 10522 - Height to Area

**Moderator:** Board moderators

### 10522 - Height to Area

I don't understand:

Area of triangle ABC = 1/2 * AC * Hb

Or AC = 2 * Area / Hb

Now, for the case "31.573 22.352 63.448",

Sample output is "222.434"

AC = 2 * 222.434 / 22.352 = 19.903

which is shorter than Ha, Hb and also Hc !!!!! How could that be?

Plz... Any hints? Thx in advance!

Area of triangle ABC = 1/2 * AC * Hb

Or AC = 2 * Area / Hb

Now, for the case "31.573 22.352 63.448",

Sample output is "222.434"

AC = 2 * 222.434 / 22.352 = 19.903

which is shorter than Ha, Hb and also Hc !!!!! How could that be?

Plz... Any hints? Thx in advance!

**7th Contest of Newbies**

**Date**: December 31st, 2011 (Saturday)

**Time**: 12:00 - 16:00 (UTC)

**URL**: http://uva.onlinejudge.org

I request you not to submit the problem.

because the online judge has put the incorrect(without the correction during the contest) problems there.

I mailed them. i think they will fix them very soon.

So please wait and sorry for the mistake..

I request you not to submit the problem.

because the online judge has put the incorrect(without the correction during the contest) problems there.

I mailed them. i think they will fix them very soon.

So please wait and sorry for the mistake..

"Everything should be made simple, but not always simpler"

So what IS the correct output?

**7th Contest of Newbies**

**Date**: December 31st, 2011 (Saturday)

**Time**: 12:00 - 16:00 (UTC)

**URL**: http://uva.onlinejudge.org

### 10522

I don't know why WA after rejudge

That is my code. Could someone tell me what's wrong?

Thx:)

[cpp]

#include <stdio.h>

#include <math.h>

double ha,hb,hc,t1,t2,t3,t4,t5,x,s;

int n;

int main()

{

scanf("%d",&n);

while(scanf("%lf %lf %lf",&ha,&hb,&hc)==3)

{

t1=hc/ha;t2=hc/hb;

t4=(1+t1+t2)*0.5;

t5=t4*(t4-1)*(t4-t1)*(t4-t2);

if(t5<=0&&!((1+t1)>t2&&(1+t2)>t1&&(t1+t2)>1))

{

puts("These are invalid inputs!");

if(--n==0) break;

}

else {

t5=sqrt(t5);

x=hc*0.5/t5;

double area=t5*x*x;

printf("%.3lf\n",area);

}

}

return 0;

}

[/cpp][/code]

That is my code. Could someone tell me what's wrong?

Thx:)

[cpp]

#include <stdio.h>

#include <math.h>

double ha,hb,hc,t1,t2,t3,t4,t5,x,s;

int n;

int main()

{

scanf("%d",&n);

while(scanf("%lf %lf %lf",&ha,&hb,&hc)==3)

{

t1=hc/ha;t2=hc/hb;

t4=(1+t1+t2)*0.5;

t5=t4*(t4-1)*(t4-t1)*(t4-t2);

if(t5<=0&&!((1+t1)>t2&&(1+t2)>t1&&(t1+t2)>1))

{

puts("These are invalid inputs!");

if(--n==0) break;

}

else {

t5=sqrt(t5);

x=hc*0.5/t5;

double area=t5*x*x;

printf("%.3lf\n",area);

}

}

return 0;

}

[/cpp][/code]

### 10522

in 10522

i carculate :

area=(a*b*c*a*b*c)/sqrt((a*b+b*c+a*c)*(a*b+b*c-a*c)*(a*b+a*c-b*c)

*(b*c+a*c-a*b))

am i wrong???

it execuate correctly when using acm's sample

what's the condition 'invalid' ???

please tell me~~ thank you very much!!!

i carculate :

area=(a*b*c*a*b*c)/sqrt((a*b+b*c+a*c)*(a*b+b*c-a*c)*(a*b+a*c-b*c)

*(b*c+a*c-a*b))

am i wrong???

it execuate correctly when using acm's sample

what's the condition 'invalid' ???

please tell me~~ thank you very much!!!

[cpp]#include <stdio.h>

#include <math.h>

int main(int argc, char *argv[])

{

int n;

double ha, hb, hc, a, b, c, d;

scanf( "%d\n", &n );

for( int i=0; i<n; ) {

scanf( "%lf %lf %lf\n", &ha, &hb, &hc );

if( (ha == 0.0 && hb == 0.0) || (ha == 0.0 && hc == 0.0) || (hb == 0.0 && hc == 0.0) )

printf( "0.000\n" );

else if( ha == 0.0 || hb == 0.0 )

printf( "These are invalid inputs!\n" );

else {

a = hc/ha;

b = hc/hb;

c = 1-a*a-b*b;

d = 4*a*a*b*b-c*c;

//printf( "%.3lf %.3lf, %.3lf, %.3lf\n", a, b, c, d);

if( d < 0 ) {

i++;

printf( "These are invalid inputs!\n" );

} else

printf( "%.3lf\n", hc*hc/sqrt(d) );

}

}

return 0;

}

[/cpp]

### ...

[quote="Maarten"]did you consider the case where either one of a,b,c is equal to zero

int AC = 2*area/b;

int BC =2*area/a;

my invalid condition is : AC<a,b,c && BC<a,b,c

and one of a,b,c equal to 0;

please give me more hints.....thank you!!

int AC = 2*area/b;

int BC =2*area/a;

my invalid condition is : AC<a,b,c && BC<a,b,c

and one of a,b,c equal to 0;

please give me more hints.....thank you!!