Page 1 of 3

10522 - Height to Area

Posted: Thu Jul 03, 2003 8:28 am
by Observer
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!

Posted: Thu Jul 03, 2003 8:52 am
by hujialie
To observer:

The sample is wrong.
If you attend this contest,you'll get it on the clarification board. :)

Correct output should be:

1517.456

Good luck.

Posted: Thu Jul 03, 2003 4:20 pm
by anupam

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..

Posted: Fri Jul 04, 2003 8:51 am
by anupam

The problems are ok.
sample in out wrong. other things are ok

Posted: Fri Jul 04, 2003 9:15 am
by Observer
So what IS the correct output?

Posted: Fri Jul 04, 2003 11:41 am
by turuthok
Output for Sample Input:
-----------------------------

1517.456
2219.941
311.804
These are invalid inputs!

Posted: Fri Jul 04, 2003 8:03 pm
by anupam
yes thats the corrected outs

Posted: Sat Jul 05, 2003 6:07 pm
by Moni
turuthok wrote:Output for Sample Input:
-----------------------------

1517.456
2219.941
311.804
These are invalid inputs!
Thanks! Turuthok! It should be in question as soon as possible! :oops:

10522

Posted: Sat Aug 23, 2003 7:14 am
by windows2k
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]

10522

Posted: Mon Oct 20, 2003 8:49 pm
by nonstop
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!!!

Posted: Tue Oct 21, 2003 11:46 am
by Maarten
did you consider the case where either one of a,b,c is equal to zero?

Posted: Tue Oct 21, 2003 12:07 pm
by Maarten
I'm getting WA too.. I think I took care of everything.. possibility that either height is zero. I assume negative height doesn't occur, I wouldn't know the meaning of it anyway. Can anybody help me? My program is here, I think it's pretty straighforward:

[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]

...

Posted: Tue Oct 21, 2003 8:38 pm
by nonstop
[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!!

Posted: Tue Oct 21, 2003 9:21 pm
by Maarten
well i'm sorry i can't really help you as i still got WA too... so maybe someone else can help us out ?

Posted: Wed Oct 22, 2003 5:29 pm
by Towhid
ha,hb,hc can be negative. Consider this case. And Marteen why u out put 0.000 when two of ha,hb,hc is 0?