第一次做凸包,用的水平序Grahm-Scan var q:array[0..3000]of longint; x,y:array[0..1100]of comp; n,m,i,j,k,r:longint; ans:double; procedure init; begin readln(n,r); for i:=1 to n do readln(x[i],y[i]); end; procedure kp(s,t:longint); var i,j:longint; xx,yy,tt:comp; begin i:=s;j:=t;xx:=x[(i+j)>>1];yy:=y[(i+j)>>1]; repeat while (y[i]<yy)or( (y[i]=yy)and(x[i]<xx) ) do inc(i); while (y[j]>yy)or( (y[j]=yy)and(x[j]>xx) ) do dec(j); if i<=j then begin tt:=y[i];y[i]:=y[j];y[j]:=tt; tt:=x[i];x[i]:=x[j];x[j]:=tt; inc(i);dec(j) end; until i>j; if i<t then kp(i,t);if j>s then kp(s,j); end; function check(a,b,c:longint):boolean; begin exit((x[b]-x[a])*(y[c]-y[a])-(x[c]-x[a])*(y[b]-y[a])>=0); end; function ll(a,b:longint):double; begin exit(sqrt(sqr(x[a]-x[b])+sqr(y[a]-y[b]))); end; procedure doit; var i,j,k,t:longint; begin kp(1,n);q[1]:=1;q[2]:=2;t:=2; for i:=3 to n do begin inc(t);q[t]:=i; while (t>2) and not check(q[t-2],q[t-1],q[t]) do begin dec(t);q[t]:=q[t+1]; end; end; for i:=n-1 downto 1 do begin inc(t);q[t]:=i; while (t>2) and not check(q[t-2],q[t-1],q[t]) do begin dec(t);q[t]:=q[t+1]; end; end; ans:=2*pi*r; for i:=1 to t-1 do ans:=ans+ll(q[i],q[i+1]); ans:=ans+ll(q[t],q[1]); writeln(round(ans)); end; begin init; doit; end.