求凸包,然后加上一个半径为L的圆周就好了。
因为每到一个凸包的顶点时,需要保持最小间距为L,则多个顶点围起来会有360度。
在输出时,不要把结果直接转化主INT,因为这个不是四舍五入。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const int MAXN=1050;
int n,l;
int st[MAXN],stop,cnt;
int ans[MAXN];
struct point{
int x,y;
}p[MAXN];
bool cmp(point A,point B){
if(A.y<B.y) return true;
else if(A.y==B.y){
if(A.x<B.x) return true;
}
return false;
}
bool multi(point a,point b,point c){
return (a.x-c.x)*(b.y-c.y)-(a.y-c.y)*(b.x-c.x)>0;
}
void slove(){
stop=0; cnt=0;
st[stop++]=0; st[stop++]=1;
for(int i=2;i<n;i++){
while(stop>1&&multi(p[st[stop-1]],p[i],p[st[stop-2]])) stop--;
st[stop++]=i;
}
for(int i=0;i<stop;i++){
ans[cnt++]=st[i];
}
stop=0;
st[stop++]=n-1; st[stop++]=n-2;
for(int i=n-3;i>=0;i--){
while(stop>1&&multi(p[st[stop-1]],p[i],p[st[stop-2]])) stop--;
st[stop++]=i;
}
for(int i=0;i<stop;i++)
ans[cnt++]=st[i];
}
double dist(point a,point b){
return sqrt((a.x-b.x)*(a.x-b.x)*1.0+(a.y-b.y)*(a.y-b.y)*1.0);
}
int main(){
while(scanf("%d%d",&n,&l)!=EOF){
for(int i=0;i<n;i++){
scanf("%d%d",&p[i].x,&p[i].y);
}
sort(p,p+n,cmp);
slove();
double anl=4*acos(0.0)*l;
for(int i=1;i<cnt;i++){
anl+=dist(p[ans[i-1]],p[ans[i]]);
}
printf("%.0lf\n",anl);
}
return 0;
}