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

I doubt the sample is wrong
Posted by Maigo Akisame 3 Jun 2004 04:50
Here's my prog which is getting WA.
According to my algo, I think the sample output should be twice the original number -- 104.09 instead of 52.04.

program ural1030;
const
  pi=3.14159265359;
  r=6875;
var
  s:string;
  longi,lati,ax,ay,az,bx,by,bz,d,si,co,angle,arc:real;
procedure recog(s:string;var angle:real);
  function value(p,q:byte):byte;
    var
      junk:word;
    begin
      val(copy(s,p,q-p+1),value,junk);
    end;
  begin
    angle:=value(1,pos('^',s)-1);
    delete(s,1,pos('^',s));
    angle:=angle+value(1,pos('''',s)-1)/60;
    delete(s,1,pos('''',s));
    angle:=angle+value(1,pos('"',s)-1)/3600;
    delete(s,1,pos('"',s));
    angle:=angle*pi/180;
    if (s[2]='S') or (s[2]='W') then angle:=-angle;
  end;
begin
  readln;readln;readln;
  readln(s);recog(s,lati);readln(s);delete(s,1,4);recog(s,longi);
  ax:=r*cos(lati)*cos(longi);ay:=r*cos(lati)*sin(longi);az:=r*sin(lati);
  readln;
  readln(s);recog(s,lati);readln(s);delete(s,1,4);recog(s,longi);
  bx:=r*cos(lati)*cos(longi);by:=r*cos(lati)*sin(longi);bz:=r*sin(lati);

  d:=sqrt(sqr(ax-bx)+sqr(ay-by)+sqr(az-bz));
  si:=d/2/r;
  co:=sqrt(1-sqr(si));
  angle:=arctan(si/co);
  arc:=r*angle*2;

  writeln('The distance to the iceberg: ',arc:0:2,' miles.');
  if arc<100 then writeln('DANGER!');
end.
Re: I doubt the sample is wrong
Posted by Maigo Akisame 3 Jun 2004 15:15
Nullify.
Re: I doubt the sample is wrong
Posted by Sandro 29 Jul 2004 23:25
The problem gives the diameter of the Earth (not radius!)