10522 - Height to Area

Moderator: Board moderators

Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

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!
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org

hujialie
New poster
Posts: 43
Joined: Thu Apr 17, 2003 10:24 am
Location: Shanghai,China
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.
Retired from SJTU Accelerator 2004

anupam
A great helper
Posts: 405
Joined: Wed Aug 28, 2002 6:45 pm
Contact:

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"

anupam
A great helper
Posts: 405
Joined: Wed Aug 28, 2002 6:45 pm
Contact:

The problems are ok.
sample in out wrong. other things are ok
"Everything should be made simple, but not always simpler"

Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong
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

turuthok
Experienced poster
Posts: 193
Joined: Thu Sep 19, 2002 6:39 am
Location: Indonesia
Contact:
Output for Sample Input:
-----------------------------

1517.456
2219.941
311.804
These are invalid inputs!
The fear of the LORD is the beginning of knowledge (Proverbs 1:7).

anupam
A great helper
Posts: 405
Joined: Wed Aug 28, 2002 6:45 pm
Contact:
yes thats the corrected outs
"Everything should be made simple, but not always simpler"

Moni
Experienced poster
Posts: 202
Joined: Fri Mar 22, 2002 2:00 am
Location: Chittagong. CSE - CUET
Contact:
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!
We are all in a circular way, no advances, only moving and moving!

windows2k
Experienced poster
Posts: 136
Joined: Sat Apr 05, 2003 3:29 pm
Location: Taiwan

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]

nonstop
New poster
Posts: 14
Joined: Fri Oct 03, 2003 5:13 am

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

Maarten
Experienced poster
Posts: 108
Joined: Sat Sep 27, 2003 5:24 pm
did you consider the case where either one of a,b,c is equal to zero?

Maarten
Experienced poster
Posts: 108
Joined: Sat Sep 27, 2003 5:24 pm
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]

nonstop
New poster
Posts: 14
Joined: Fri Oct 03, 2003 5:13 am

...

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

Maarten
Experienced poster
Posts: 108
Joined: Sat Sep 27, 2003 5:24 pm
well i'm sorry i can't really help you as i still got WA too... so maybe someone else can help us out ?

Towhid
New poster
Posts: 38
Joined: Wed May 28, 2003 5:30 pm