ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1294. Mars Satellites

{$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.
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 ).
vano_B1 HO-HO-HO // Problem 1294. Mars Satellites 8 Jul 2004 16:15
...то выведите "Impossible.", иначе...
"Impossible{.}"
who said the numbers were double? they are small integers...
And the formula is very good...
working formula =) nice