#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. 洛谷 P4720 【模板】扩展 / 卢卡斯 模板题

    扩展卢卡斯定理 : https://www.luogu.org/problemnew/show/P4720 卢卡斯定理:https://www.luogu.org/problemnew/show/P3 ...

  2. 从零开始写STL—模板元编程之any

    any class any; (since C++17) The class any describes a type-safe container for single values of any ...

  3. delphi操作xml学习笔记 之一 入门必读

    Delphi 对XML的支持---TXMLDocument类       Delphi7 支持对XML文档的操作,可以通过TXMLDocument类来实现对XML文档的读写.可以利用TXMLDocum ...

  4. 转 linux socket的select函数例子

    使用select函数可以以非阻塞的方式和多个socket通信.程序只是演示select函数的使用,功能非常简单,即使某个连接关闭以后也不会修改当前连接数,连接数达到最大值后会终止程序. 1. 程序使用 ...

  5. Scala入门到精通——第十六节 泛型与注解

    本节主要内容 泛型(Generic Type)简单介绍 注解(Annotation)简单介绍 注解经常使用场景 1. 泛型(Generic Type)简单介绍 泛型用于指定方法或类能够接受随意类型參数 ...

  6. 碰撞检測之Sphere-Box检測

    检測思路 首先要做的是将Box转为AABB,然后推断圆心是否在Box内.用的就是之前的SAT 假设圆心在Box内,肯定相交, 假设不在圆心内.则有四种情况,与顶点相交,与楞相交,与面相交,这里的确定也 ...

  7. HDU 5288(OO’s Sequence-区间互质情况统计)

    OO's Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  8. Android经常使用设计模式(二)

    继上一篇 Android经常使用设计模式(一)里认识了观察者.适配器.代理等三种模式,这一篇将会解说下面三种模式: 工厂模式 单例模式 命令模式 1.工厂模式(Factory Pattern) 工厂模 ...

  9. Cocos2dx 小技巧(十三)聊聊坐标系

    一好友考上了空姐.她说:以后基本上不会回来了.等下次见面时请叫我白富美!尽管有点羡慕.但我依然不甘示弱回复:下次见面时请叫我高富帅! 未来,谁说得准呢? ------------------有段时间没 ...

  10. 内存转储文件 Memory.dmp

    https://baike.sogou.com/v63435711.htm?fromTitle=内存转存文件 内存转储是用于系统崩溃时,将内存中的数据转储保存在转储文件中,供给有关人员进行排错分析用途 ...