hdu 1348【凸包模板】
#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【凸包模板】的更多相关文章
- hdu 1348 凸包模板
http://acm.hdu.edu.cn/showproblem.php?pid=1348 造城墙问题,求出凸包加上一圈圆的周长即可 凸包模板题 #include <cstdio> #i ...
- HDU 1392 凸包模板题,求凸包周长
1.HDU 1392 Surround the Trees 2.题意:就是求凸包周长 3.总结:第一次做计算几何,没办法,还是看了大牛的博客 #include<iostream> #inc ...
- hdu 1348(凸包)
Wall Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- hdu 1348 Wall (凸包)
Wall Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- 计算几何(凸包模板):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 ...
- hdu 2202 最大三角形_凸包模板
题意:略 思路:直接套用凸包模板 #include <iostream> #include <cstdio> #include <cmath> #include & ...
- hdu 1686 KMP模板
// hdu 1686 KMP模板 // 没啥好说的,KMP裸题,这里是MP模板 #include <cstdio> #include <iostream> #include ...
- HDU 1392 凸包
Surround the Trees Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- 凸包模板 POJ1873
// 凸包模板 POJ1873 // n=15所以可以按位枚举求凸包,再记录数据 #include <iostream> #include <cstdio> #include ...
- HDU 4946 凸包
给你n个点,具有速度,一个位置如果有其他点能够先到,则不能继续访问,求出里面这些点哪些点是能够无限移动的. 首先我们考虑到,一个速度小的和一个速度大的,速度小的必定只有固定他周围的一定区域是它先到的, ...
随机推荐
- uva 10559
记忆话搜索 DP 看了网上题解 状态方程真是巧妙 orz #include <cstdio> #include <cstdlib> #include <cmath> ...
- 学习日常笔记<day12>jsp基础
1.Jsp基础 1.1Jsp引入 Servlet的作用:用java语言开发动态资源的技术 Jsp的作用:用java语言(+html语言)开发动态资源的技术 jsp就是servlet 1.2Jsp的特点 ...
- Java日志框架使用技巧收集(slf4j、jcl、jul、log4j1、log4j2、logback)
乒乓狂魔-教程: jdk-logging.log4j.logback日志介绍及原理 commons-logging与jdk-logging.log4j1.log4j2.logback的集成原理 slf ...
- sublime text 3注册码
—– BEGIN LICENSE —– Michael Barnes Single User License EA7E-821385 8A353C41 872A0D5C DF9B2950 AFF6F6 ...
- poj2481 Cows
Description Farmer John's cows have discovered that the clover growing along the ridge of the hill ( ...
- 解决运行scrapy是报错No module named cryptography,解决cryptography的安装问题,解决libffi的安装问题
在linux下配置完运行是出现ImportError: No module named cryptography.hazmat.bindings.openssl.binding的错误.原因是crapt ...
- POJ训练计划2299_Ultra-QuickSort(线段树/单点更新)
解题报告 题意: 求逆序数. 思路: 线段树离散化处理. #include <algorithm> #include <iostream> #include <cstri ...
- 安装PyQt5和Eric6
安装官方的指引,安装起来本来是非常简单的,但是我前后折腾了两天,甚至连Eric得源码都去调试都没成功.过程如下: 在PyQt5的官网链接中下载轮子 PyQt5-5.7.1-5.7.1-cp34.cp3 ...
- mt7620 uboot
我本机装的是64位Ubuntu, SDK 里提供的 buildroot-gcc342 是32位的,无法直接运行,需要先安装 gcc-multilib. sudo apt-get install gcc ...
- phpqrcode生成带logo的二维码图片及带文字的二维码图片
<?php require_once "./phpqrcode/phpqrcode.php"; /** * 这样就可以生成二维码了,实际上在png这个方法里还有几个参数需要使 ...