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

Some Help
Posted by PersonalJesus 9 Dec 2008 04:02
Don't forget to use abs.. It really gave me some headaches why I receive WA#2 :)
Re: Some Help
Posted by MOPDOBOPOT 13 Mar 2009 19:44
yes,yes=) thank you)
But now i got WA#3 =(
whats wrong?
program lam;
var xa,ya,xb,yb,xc,yc,ab,bc,ac,res,sk1,sk2,l,max,min: real;
begin
read(xa,ya,xb,yb,xc,yc,l);
ab:=sqrt(sqr(xa-xb)+sqr(ya-yb));
ac:=sqrt(sqr(xa-xc)+sqr(ya-yc));
bc:=sqrt(sqr(xc-xb)+sqr(yc-yb));
sk1:=((xc-xb)*(xa-xb)+(yc-yb)*(ya-yb));
sk2:=((xc-xa)*(xb-xa)+(yc-ya)*(yb-ya));
if ab=0 then begin
if l>ac then begin writeln('0.00'); writeln('0.00'); end else begin
writeln((ac-l):0:2);
writeln((ac-l):0:2);
end;
halt;
end;
if (sk1>0) and (sk2>0) then begin
res:=abs((abs(xc-xb)*abs(ya-yb)-abs(xa-xb)*abs(yc-yb)))/ab;
if l>res then writeln('0.00') else writeln((res-l):0:2);
if bc>ac then max:=bc else max:=ac;
if l>max then writeln('0.00') else writeln((max-l):0:2);
end;
if (sk1<0) or (sk2<0) then begin
if bc>ac then begin max:=bc; min:=ac; end else begin max:=ac; min:=bc; end;
if l>min then writeln('0.00') else writeln((min-l):0:2);
if l>max then writeln('0.00') else writeln((max-l):0:2);
end;
if (sk1=0) or (sk2=0) then begin
res:=(abs(xc-xb)*abs(ya-yb)-abs(xa-xb)*abs(yc-yb))/ab;
if l>res then writeln('0.00') else writeln((res-l):0:2);
if bc=res then
if l>ac then writeln('0.00') else writeln((ac-l):0:2);
if ac=res then
if l>bc then writeln('0.00') else writeln((bc-l):0:2);
end;
end.

Edited by author 13.03.2009 20:01