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

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.
Posted by Danica Porobic 1 Jun 2004 01:04
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
Posted by vano_B1 8 Jul 2004 16:15
...то выведите "Impossible.", иначе...
"Impossible{.}"
Re: Why should I got WA2? It seems very easy to solve.
Posted by Gheorghe Stefan 28 Jul 2004 18:42
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