#include<iostream>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=1005;
const double eps=1e-8;
int T,n,r,w,top;
struct dian
{
double x,y;
dian(double X=0,double Y=0)
{
x=X,y=Y;
}
dian operator + (const dian a) const
{
return dian(x+a.x,y+a.y);
}
dian operator - (const dian a) const
{
return dian(x-a.x,y-a.y);
}
}p[N],s[N],d;
int cj(dian a,dian b)
{
return a.x*b.y-a.y*b.x;
}
double dis(dian a,dian b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
bool cmp(const dian &a,const dian &b)
{
double ar=cj(a-d,b-d);
return (ar>0)||((ar==0)&&a.x<b.x);
}
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&r);
d.x=d.y=10000;top=0;
for(int i=1;i<=n;i++)
{
scanf("%lf%lf",&p[i].x,&p[i].y);
if(p[i].x<d.x||(p[i].x==d.x&&p[i].y<d.y))
d=p[i],w=i;
}//cout<<endl<<d.x<<" "<<d.y<<endl;
n--;
for(int i=w;i<=n;i++)
p[i]=p[i+1];
sort(p+1,p+1+n,cmp);
// for(int i=1;i<=n;i++)
// printf("%f %f\n",p[i].x,p[i].y);
s[++top]=d,s[++top]=p[1];
for(int i=2;i<=n;i++)
{
while(top>1&&cj(s[top]-p[i],s[top-1]-p[i])>=0)
top--;
s[++top]=p[i];
}
double ans=2.0*3.1415926*(double)r;//cout<<ans<<endl;
s[0]=s[top];
for(int i=1;i<=top;i++)
ans+=dis(s[i-1],s[i]);//,cout<<s[i].x<<" "<<s[i].y<<endl;
printf("%.0lf\n",ans);
if(T)
puts("");
}
return 0;
}

hdu 1348【凸包模板】的更多相关文章

  1. hdu 1348 凸包模板

    http://acm.hdu.edu.cn/showproblem.php?pid=1348 造城墙问题,求出凸包加上一圈圆的周长即可 凸包模板题 #include <cstdio> #i ...

  2. HDU 1392 凸包模板题,求凸包周长

    1.HDU 1392 Surround the Trees 2.题意:就是求凸包周长 3.总结:第一次做计算几何,没办法,还是看了大牛的博客 #include<iostream> #inc ...

  3. hdu 1348(凸包)

    Wall Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  4. hdu 1348 Wall (凸包)

    Wall Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  5. 计算几何(凸包模板):HDU 1392 Surround the Trees

    There are a lot of trees in an area. A peasant wants to buy a rope to surround all these trees. So a ...

  6. hdu 2202 最大三角形_凸包模板

    题意:略 思路:直接套用凸包模板 #include <iostream> #include <cstdio> #include <cmath> #include & ...

  7. hdu 1686 KMP模板

    // hdu 1686 KMP模板 // 没啥好说的,KMP裸题,这里是MP模板 #include <cstdio> #include <iostream> #include ...

  8. HDU 1392 凸包

    Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  9. 凸包模板 POJ1873

    // 凸包模板 POJ1873 // n=15所以可以按位枚举求凸包,再记录数据 #include <iostream> #include <cstdio> #include ...

  10. HDU 4946 凸包

    给你n个点,具有速度,一个位置如果有其他点能够先到,则不能继续访问,求出里面这些点哪些点是能够无限移动的. 首先我们考虑到,一个速度小的和一个速度大的,速度小的必定只有固定他周围的一定区域是它先到的, ...

随机推荐

  1. oc温习八:static、extern、const 的了解

    参考文章:http://www.cocoachina.com/ios/20161110/18035.html 1.const 这个单词翻译成中文是“常量”的意思.在程序中我们知道“常量”的值是不能变的 ...

  2. tomcat启动提示java.lang.UnsatisfiedLinkError: D:\soft\devTool\apache-tomcat-7.0.57\bin\tcnative-1.dll: C

    https://blog.csdn.net/a274360781/article/details/52411984

  3. BZOJ 4894 有向图 外向生成树个数

    4894: 天赋 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 191  Solved: 150[Submit][Status][Discuss] D ...

  4. Codeforces 618C(计算几何)

    C. Constellation time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  5. 【小记事】解除端口占用(Windows)

    开发中有时会因为端口占用而导致起项目时报错(如下图),这时候只要解除端口占用即可. 解除端口占用: 1.打开cmd(win+r),查看端口占用情况 netstat -ano | findstr 端口号 ...

  6. 洛谷—— P2802 回家

    P2802 回家 题目描述 小H在一个划分成了n*m个方格的长方形封锁线上. 每次他能向上下左右四个方向移动一格(当然小H不可以静止不动), 但不能离开封锁线,否则就被打死了. 刚开始时他有满血6点, ...

  7. 洛谷—— P2812 校园网络

    P2812 校园网络 题目背景 浙江省的几所OI强校的神犇发明了一种人工智能,可以AC任何题目,所以他们决定建立一个网络来共享这个软件.但是由于他们脑力劳动过多导致全身无力身体被♂掏♂空,他们来找你帮 ...

  8. [NOI2012(bzoj2879)(vijos1726)]美食节 (费用流)

    2879: [Noi2012]美食节 Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 2288  Solved: 1207[Submit][Status ...

  9. 转: 将Eclipse代码导入到AndroidStudio的两种方式

    评注: 讲解的非常之详细 转自:    http://www.cnblogs.com/ct2011/p/4183553.html 说到使用AndroidStudio,除了新建的项目,我们都会面临的问题 ...

  10. wsdl2objc定制(一)namespace

    1.问题抛出: 如今还是有非常多人使用 wsdl2objc 来调用webservice,可是有时候会有不开心的事情发生, <soap:Envelope xmlns:soap="http ...