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

Please could you look at my prog please.
Posted by Nurbek 15 Jan 2006 00:14
I've solved this problem but still have WA on test 3.
Could you give me this test or find my mistake plz.
var
l,k,j:integer;
d,d1,d2,m,b:real; t:boolean;
x,y,x1,y1,x2,y2:integer;
label con;
begin
read(x1,y1,x2,y2,x,y,l);
if (((x>=x1)and(x<=x2))or((y>=y1)and(y<=y2)))or
(((x<=x1)and(x>=x2))or((y<=y1)and(y>=y2))) then
 begin
if x2-x1>0 then m:=(y2-y1)/(x2-x1)
else m:=0;
b:=y1-m*x1;
if y=m*x+b then begin d:=0; goto con;end;
if ((m=0)and(y1=y2))or((m=0)and(x1=x2)) then
 begin
 if y1=y2 then d:=abs(y1-y);
 if x1=x2 then d:=abs(x1-x);
 end
else d:=abs(m*x+b-y)/sqrt(m*m);
con:if d-l>0 then writeln((d-l):0:2)
else writeln((1.00-1.00):0:2);
d1:=sqrt(sqr(x-x1)+sqr(y-y1));
d2:=sqrt(sqr(x-x2)+sqr(y-y2));
if (d1>=d2)and(d1-l>=0) then
begin writeln((d1-l):0:2); t:=true;end;
if (d2>d1)and(d2-l>0) then
begin writeln((d2-l):0:2); t:=true;end;
if t=false then write((1.00-1.00):0:2);
t:=false;
halt;
end;
d1:=sqrt(sqr(x-x1)+sqr(y-y1));
d2:=sqrt(sqr(x-x2)+sqr(y-y2));
if (d1>=d2)and(d2-l>=0) then writeln((d2-l):0:2);
if (d1<d2)and(d1-l>0) then writeln((d1-l):0:2);
if (d1>=d2)and(d1-l>=0) then writeln((d1-l):0:2) ;
if (d1<d2)and(d2-l>0) then writeln((d2-l):0:2) ;
end.