I think my program is quite right,but it get WA!!!
{$A+,B-,D+,E+,F-,G-,I+,L+,N+,O-,P-,Q-,R-,S+,T-,V+,X+,Y+}
{$M 65520,0,655360}
type uu=record
x,y:longint;
end;
var zuob:array[1..101] of uu;
n,i,b:integer;
a1,a2,b1,b2,c1,c2,x,y,x1,x2,y1,y2,xj,yj,xp,yp,ans,min,l1,l2:extended;
procedure xyz(a1,b1,c1,a2,b2,c2:extended;var x,y:extended);
begin
x:=(b1*c2-b2*c1)/(a1*b2-a2*b1);
y:=(c1*a2-c2*a1)/(a1*b2-a2*b1);
end;
function distan(x1,y1,x2,y2:extended):extended;
begin
distan:=sqrt(abs(sqr(x1-x2))+abs(sqr(y1-y2)));
end;
begin
readln(xp,yp,n);
for i:=1 to n do readln(zuob[i].x,zuob[i].y);
zuob[n+1]:=zuob[1];
b:=0;
for i:=1 to n do
begin
if (zuob[i].x-xp)*(zuob[i+1].y-yp)-(zuob[i].y-yp)*(zuob[i+1].x-xp)
>0 then b:=1;
end;
if b=0 then begin writeln('0.000'); halt; end;
ans:=1e+10;
for i:=1 to n do
begin
a1:=zuob[i].y-zuob[i+1].y;
b1:=zuob[i].x-zuob[i+1].x;
c1:=(zuob[i+1].y-zuob[i].y)*zuob[i+1].x+(zuob[i].x-zuob[i+1].x)
*zuob[i+1].y;
a2:=-b1;
b2:=a1;
c2:=-(a2*xp+b2*yp);
xyz(a1,b1,c1,a2,b2,c2,xj,yj);
{ xj:=(b1*c2-b2*c1)/(a1*b2-a2*b1);
yj:=(c1*a2-c2*a1)/(a1*b2-a2*b1);}
if ((zuob[i].x-xj)*(zuob[i+1].x-xj)<=0)and
((zuob[i].y-yj)*(zuob[i+1].y-yj)<=0) then
min:=distan(xp,yp,xj,yj) else
begin
l1:=distan(xp,yp,zuob[i].x,zuob[i].y);
if l1<1e-14 then l1:=0;
l2:=distan(xp,yp,zuob[i+1].x,zuob[i+1].y);
if l1<l2 then min:=l1
else min:=l2;
end;
if min<ans then ans:=min;
end;
writeln(ans*2:0:3);
end.