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

how an i concrete this prog, here is code.
Posted by Bobur 19 Mar 2008 00:04
program Project1075_chala;

{$APPTYPE CONSOLE}

uses
  SysUtils, math;

  const
  EPS = 0.0000001;

    var
    xa, xb, xc, ya, yb, yc, za, zb, zc, r : integer;
    AB, BC, AC, cos_gamma, cos_gamma1, yoy, vatar, d, h : real;

begin
   read(xa, ya, za);
   read(xb, yb, zb);
   read(xc, yc, zc);
   read(r);
   AB := sqrt(sqr(xb-xa)+sqr(yb-ya)+sqr(zb-za));
   AC := sqrt(sqr(xc-xa)+sqr(yc-ya)+sqr(zc-za));
   BC := sqrt(sqr(xb-xc)+sqr(yb-yc)+sqr(zb-zc));
   if AB + BC <= AC+EPS then d := AB-2*r+PI*r
   else
     if (AC+EPS >= BC + AB) or (BC+EPS >= AC + AB) then d := AB
     else
       begin
         cos_gamma := (AC*AC+BC*BC-AB*AB)/(2*AC*BC);
         h := AC*BC*sqrt(1 - sqr(cos_gamma))/AB;
       if h+EPS >= r then d := AB
       else
         begin
           vatar := 2 * sqrt(sqr(r)-sqr(h));
           cos_gamma1 := (2*sqr(r)-sqr(vatar))/(2*r*r);
           yoy := arccos(cos_gamma1) * r;
           d := AB - vatar + yoy;
         end;
       end;
   writeLn(d:0:2);
end.

thanks
here new code, but yet answer is 19.87, help
Posted by Bobur 23 Mar 2008 21:09
  const
  EPS = 0.000001;

    var
    xa, xb, xc, ya, yb, yc, za, zb, zc, r : integer;
    c, a, b, yoy, vatar, d, h : real;

begin
   read(xa, ya, za);
   read(xb, yb, zb);
   read(xc, yc, zc);
   read(r);
   c := sqr(xa-xb)+sqr(ya-yb)+sqr(za-zb);     //AB^2
   d := sqrt(c);
   b := sqr(xa-xc)+sqr(ya-yb)+sqr(za-zc);     //AC^2
   a := sqr(xb-xc)+sqr(yb-yc)+sqr(zb-zc);     //BC^2
   h := (4*a*b-sqr(a+b-c))/(4*c);
   if sqrt(h) < r then
     if sqrt(b-h)+sqrt(a-h)-EPS<=d then
       begin
         vatar := 2*sqrt(sqr(r)-h);
         yoy := r*arccos((2*h-sqr(r))/(r*r));
         d := d - vatar + yoy;
       end;
   writeLn(d:0:2);
end.
Re: here new code, but yet answer is 19.87, help
Posted by Piratek-(akaDK) 9 Feb 2009 18:07
Solution is wrong, because you must search for kasatelnye(russian word)
Re: here new code, but yet answer is 19.87, help
Posted by Sandello 30 Jan 2010 23:22
kasatelnye == tangent