ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1030. Титаник

Показать все сообщения Спрятать все сообщения

I doubt the sample is wrong Maigo Akisame 3 июн 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 Maigo Akisame 3 июн 2004 15:15
Nullify.
Re: I doubt the sample is wrong Sandro 29 июл 2004 23:25
The problem gives the diameter of the Earth (not radius!)