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 1348. Goat in the Garden 2

WA#@21
Posted by Dmitrij Bolshakov (Orenburg SU 06RPh) 17 Aug 2007 02:49
help me!
const
n=2;
var
i,l:longint;
q,w,e:array[1..n] of longint;
a,b,c,p,h,r:real;
Begin
for i:=1 to 2 do
read(q[i]);
for i:=1 to 2 do
read(w[i]);
for i:=1 to 2 do
read(e[i]);
read(l);
if q[1]-w[1]=0 then h:=abs(e[1]-w[1])
                else h:=abs(e[2]-q[2]-(w[2]-q[2])*(e[1]-q[1])/(w[1]-q[1]))/sqrt(1+sqr((w[2]-q[2])/(w[1]-q[1])));
c:=sqrt(sqr(q[2]-w[2])+sqr(q[1]-w[1]));
a:=sqrt(sqr(e[2]-w[2])+sqr(e[1]-w[1]));
b:=sqrt(sqr(q[2]-e[2])+sqr(q[1]-e[1]));
if a*a+b*b<c*c then h:=h
               else
               begin
               if a*a+c*c<b*b then h:=a;
               if b*b+c*c<a*a then h:=b;
               end;
if h>l then h:=h-l
       else h:=0;
writeln(h:5:2);
if a>b then begin if a>l then r:=a-l
                         else r:=0;
            end
       else begin if b>l then r:=b-l
                         else r:=0;
            end;
writeln(r:5:2);
readln;
readln;
end.

Edited by author 17.08.2007 02:59