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 1075. Thread in a Space

Show all messages Hide all messages

Who can help me? I got WA!!! Bighead 22 Apr 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 May 2002 19:00
........................................
........................................
........................................
........................................
........................................
..........*****.........................
.......***********........*......*......
......*************.....................
......*************.....................
.......***********......................
..........*****.........................
........................................
........................................
........................................
........................................
........................................
........................................
!!! D<R !!!
Thanks very much,I jusft lost in this trick!I got AC now!! daizi sheng(from USTC) 19 Oct 2002 08:37
> ........................................
> ........................................
> ........................................
> ........................................
> ........................................
> ..........*****.........................
> .......***********........*......*......
> ......*************.....................
> ......*************.....................
> .......***********......................
> ..........*****.........................
> ........................................
> ........................................
> ........................................
> ........................................
> ........................................
> ........................................
> !!! D<R !!!
>
>