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

Обсуждение задачи 1075. Нитка в пространстве

Who can help me? I got WA!!!
Послано Bighead 22 апр 2002 15:31
I think my program is right, but it got WA. Who can help me find the
error?

Here is my code:

program U1075;
var
  p:Array[1..3,1..3] of longint;{a,b,c}
  pp,s,d,a,b,l,res:real;
  r,i,j:longint;
  al,be,th:real;
  sac,sbc,sab:longint;

  function arccos(x:real):real;
  begin
    if abs(x)<1e-5 then arccos:=pi/2
      else if abs(x-1)<1e-5 then arccos:=0
        else ArcCos:= ArcTan (sqrt (1-sqr (x)) /x)
  end;

begin
  for i:=1 to 3 do
    for j:=1 to 3 do
      read(p[i,j]);
  readln(r);
  sac:=sqr(p[1,1]-p[3,1])+sqr(p[1,2]-p[3,2])+sqr(p[1,3]-p[3,3]);
  sbc:=sqr(p[2,1]-p[3,1])+sqr(p[2,2]-p[3,2])+sqr(p[2,3]-p[3,3]);
  sab:=sqr(p[1,1]-p[2,1])+sqr(p[1,2]-p[2,2])+sqr(p[1,3]-p[2,3]);
  if sab=0 then begin
    writeln('0.00');
    halt;
  end;
  a:=sqrt(sac);b:=sqrt(sbc);l:=sqrt(sab);
  pp:=(a+b+l)/2;
  s:=sqrt(pp)*sqrt(abs(pp-a))*sqrt(abs(pp-b))*sqrt(abs(pp-l));
  d:=2*s/l;
  if d-r>=1e-5 then
    writeln(l:0:2)
  else begin
    al:=arccos(d/a)+arccos(d/b);
    be:=pi/2-arccos(sqrt(sac-sqr(r))/a);
    th:=pi/2-arccos(sqrt(sbc-sqr(r))/b);
    res:=sqrt(sac-sqr(r))+sqrt(sbc-sqr(r));
    res:=res+r*(al-be-th);
    writeln(res:0:2);
  end;
end.
I think this picture Might Help...
Послано Alex[LSD] 11 май 2002 19:00
........................................
........................................
........................................
........................................
........................................
..........*****.........................
.......***********........*......*......
......*************.....................
......*************.....................
.......***********......................
..........*****.........................
........................................
........................................
........................................
........................................
........................................
........................................
!!! D<R !!!
Thanks very much,I jusft lost in this trick!I got AC now!!
Послано daizi sheng(from USTC) 19 окт 2002 08:37
> ........................................
> ........................................
> ........................................
> ........................................
> ........................................
> ..........*****.........................
> .......***********........*......*......
> ......*************.....................
> ......*************.....................
> .......***********......................
> ..........*****.........................
> ........................................
> ........................................
> ........................................
> ........................................
> ........................................
> ........................................
> !!! D<R !!!
>
>