Help please... WA4...
{$APPTYPE CONSOLE}
{$n+}
uses
SysUtils;
type
tpoint=record
x,y:{longint} extended;
end;
const
maxn=200;
var
a:array[1..maxn] of tpoint;
n:longint;
min:extended;
f:tpoint;
procedure init;
var
i:longint;
begin
assign(input,'input.txt');
reset(input);
assign(output,'output.txt');
rewrite(output);
readln(f.x,f.y,n);
for i:=1 to n do
readln(a[i].x,a[i].y);
inc(n);
a[n+1].x:=a[1].x;
a[n+1].y:=a[1].y;
min:=maxlongint;
end;
function scalmul(p1,p2,p3,p4:tpoint):extended;
begin
scalmul:=(p2.x-p1.x)*(p4.x-p3.x)+(p2.y-p1.y)*(p4.y-p3.y);
end;
function rast(p1,p2:tpoint):extended;
begin
rast:=sqrt(sqr(p2.x-p1.x)+sqr(p2.y-p1.y));
end;
function vecmul(p1,p2,p3,p4:tpoint):extended;
begin
vecmul:=(p2.x-p1.x)*(p4.y-p3.y)-(p2.y-p1.y)*(p4.x-p3.x);
end;
function prov:boolean;
var
i,j:longint;
b:boolean;
begin
b:=true;
for i:=1 to n-1 do
if vecmul(a[i],f,a[i],a[i+1])>=0 then begin
if b then b:=false;
end;
prov:=b;
end;
procedure solve;
var
i,j,im,l,r:longint;
h:extended;
begin
if prov then begin
writeln(0.0:0:3);
halt;
end;
dec(n);
for i:=1 to n do
if rast(f,a[i])<min then begin
min:=rast(f,a[i]);
im:=i;
end;
l:=i-1;
r:=i+1;
if l<1 then inc(l,n);
if r>n then dec(r,n);
if (scalmul(a[l],f,a[l],a[im])>0) and (scalmul(a[im],f,a[im],a[l])>0) then begin
h:=vecmul(f,a[im],f,a[l])/rast(a[im],a[l]);
if min>h then min:=h;
end;
if (scalmul(a[r],f,a[r],a[im])>0) and (scalmul(a[im],f,a[im],a[r])>0) then begin
h:=vecmul(f,a[im],f,a[r])/rast(a[im],a[r]);
if min>h then min:=h;
end;
end;
procedure done;
begin
writeln(abs(min*2):0:3);
end;
begin
init;
solve;
done;
end.
Re: Help please... WA4...
I didn't understand where was the mistake in the code... if you have true code can you send me it on my e-mail, please?
my e-mail : liwang@mail.ru
I can send you any code if I have solved it. don't look to my account. just send me the number that you want. if I have it I will send you in return for this problem. thank you