Why should I got WA2? It seems very easy to solve.

Posted by

z 27 May 2004 18:12

{$N+}

Program Mars_satellites;

Var

cos_,x,a,b,c,d:Double;

Begin

Readln(a,b,c,d);

If (a*b-c*d)=0 Then

Begin

Write('Impossible');

End

Else

Begin

cos_:=a*a+b*b-c*c-d*d;

cos_:=cos_/(2*a*b-2*c*d);

x:=a*a+b*b-2*a*b*cos_;

x:=sqrt(x);

x:=round(1000*x);

Write('Distance is ',x:0:0,' km.');

End;

End.

Re: Why should I got WA2? It seems very easy to solve.

Hi,

your program has two mistakes, first one is (a*b-c*d)=0, equlity cannot be tested with doubles that way, you should use Abs(a*b-c*d)<e instead, where e is very small value, in this case e=0.01 is enough; second mistake is the formula I think, try to solve the math part of this problem again. If you want I can send you my AC program ( or just it's formula ).

HO-HO-HO

...то выведите "Impossible.", иначе...

"Impossible{.}"

Re: Why should I got WA2? It seems very easy to solve.

who said the numbers were double? they are small integers...

And the formula is very good...

Re: Why should I got WA2? It seems very easy to solve.

Posted by

ivan 7 Apr 2012 23:45

working formula =) nice