|
|
вернуться в форумWhy WA on test 5 ? var x1, y1, x2, y2, x0, y0, x, y, l, l1, l2, d, k, k1: double; begin read(x1, y1, x2, y2, x0, y0, l); k:= (y2 - y1) / (x2 - x1 + 1e-8); k1:= - 1 / (k + 1e-8); x:= (k * x1 - y1 - k1 * x0 + y0) / (k - k1 + 1e-8); y:= k * (x - x1) + y1; l1:= sqrt(sqr(x0 - x1) + sqr(y0 - y1)); l2:= sqrt(sqr(x0 - x2) + sqr(y0 - y2)); if (abs(x1 - x) < 1e-8) or (abs(x2 - x) < 1e-8) or ((x1 - x) * (x2 - x) < 0) then d:=sqrt(sqr(x0 - x) + sqr(y0 - y)) else d:=1e12; if l1 < d then d:= l1; if l2 < d then d:= l2; if d > l then writeln(d - l:0:2) else writeln('0.00'); d:= l1; if d < l2 then d:= l2; if d > l then writeln(d - l:0:2) else writeln('0.00'); end. Can somebody give me some special case? Re: Why WA on test 5 ? Did you treat the cases in which the triangle is obtuse and acute? Re: no Послано Dr.No 4 апр 2006 00:56 you used linear equation but that's wrong. You have to find the distance between a point and a segment,not between a point and a line. Distance between a point and a line is shorter sometimes. |
|
|