http://poj.org/problem?id=1113

不多说...凸包网上解法很多,这个是用graham的极角排序,也就是算导上的那个解法

其实其他方法随便乱搞都行...我只是测一下模板...

struct POINT{
double x,y;
POINT(double _x = , double _y = ):x(_x),y(_y){};
};
POINT p[MAXN],s[MAXN];
double dist(POINT p1,POINT p2){
return(sqrt((p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y)));
}
double multiply(POINT sp,POINT ep,POINT op){
return (sp.x-op.x) * (ep.y-op.y) - (ep.x-op.x) * (sp.y-op.y);
}
bool ptcmp(POINT a,POINT b){ // 极角排序cmp p[]为全局变量
if(multiply(a,b,p[]) == ) return dist(p[],a) < dist(p[],b);
return (multiply(a,b,p[]) > );
}
int Graham_scan(POINT p[],POINT s[],int n){ // 返回凸包点的个数
int i,k = ,top = ;
for(i = ; i < n ; i++) // 取y最小且x最小的点为凸包起点
if((p[i].y < p[k].y) || ((p[i].y == p[k].y) && (p[i].x < p[k].x)))
k = i;
swap(p[],p[k]); // 起点设置为p[0]
sort(p+,p+n,ptcmp); // 极角排序
for(i = ; i < ; i++)
s[i] = p[i]; // 前三个点入栈
for(i = ; i < n ; i++){
while(multiply(p[i],s[top],s[top-]) >= )
top--;
s[++top] = p[i];
}
return top + ;
}
int main()
{
int a,b,n;
double r;
while(~scanf("%d%lf",&n,&r)){
for(int i = ; i < n ; i++)
scanf("%lf%lf",&p[i].x,&p[i].y);
int len = Graham_scan(p,s,n);
double sum = dist(s[len-],s[]);
for(int i = ; i < len- ; i++){
sum += dist(s[i],s[i+]);
}
sum += (PI*r*);
cout<<floor(sum+0.5)<<endl;
}
return ;
}

POJ 1113 Wall 求凸包的更多相关文章

  1. POJ 1113 Wall 求凸包的两种方法

    Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 31199   Accepted: 10521 Descriptio ...

  2. Wall - POJ 1113(求凸包)

    题目大意:给N个点,然后要修建一个围墙把所有的点都包裹起来,但是要求围墙距离所有的点的最小距离是L,求出来围墙的长度. 分析:如果没有最小距离这个条件那么很容易看出来是一个凸包,然后在加上一个最小距离 ...

  3. POJ 1113 Wall【凸包周长】

    题目: http://poj.org/problem?id=1113 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...

  4. POJ 1113 Wall (凸包)

    Description Once upon a time there was a greedy King who ordered his chief Architect to build a wall ...

  5. POJ 1113 Wall(计算几何の凸包)

    Description Once upon a time there was a greedy King who ordered his chief Architect to build a wall ...

  6. POJ 1113 Wall(凸包)

    [题目链接] http://poj.org/problem?id=1113 [题目大意] 给出一个城堡,要求求出距城堡距离大于L的地方建围墙将城堡围起来求所要围墙的长度 [题解] 画图易得答案为凸包的 ...

  7. 2018.07.04 POJ 1113 Wall(凸包)

    Wall Time Limit: 1000MS Memory Limit: 10000K Description Once upon a time there was a greedy King wh ...

  8. 题解报告:poj 1113 Wall(凸包)

    Description Once upon a time there was a greedy King who ordered his chief Architect to build a wall ...

  9. poj 1113 Wall 凸包的应用

    题目链接:poj 1113   单调链凸包小结 题解:本题用到的依然是凸包来求,最短的周长,只是多加了一个圆的长度而已,套用模板,就能搞定: AC代码: #include<iostream> ...

随机推荐

  1. Project Euler:Problem 58 Spiral primes

    Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side length ...

  2. Exception: Operation xx of contract xx specifies multiple request body parameters to be serialized without any wrapper elements.

    Operation 'CreateProductCodeStock' of contract 'IChileService' specifies multiple request body param ...

  3. hdoj--2955--Robberies(背包好题)

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

  4. centos 7.3 配置vnc 服务 图形界面登录

    1.检查系统是否有安装tigervnc-server软件包 rpm -qa |grep vnc 默认的系统未装tigervnc-server软件包 2.安装tigervnc-server软件包 yum ...

  5. Oracle 排序中 nulls first 与 nulls last 的用法

    Nulls first和nulls last是Oracle Order by支持的语法 如果Order by 中指定了表达式Nulls first则表示null值的记录将排在最前(不管是asc 还是 ...

  6. 打开文件对话框在xp和win7上的实现文件任意多选

    作者:朱金灿 来源:http://blog.csdn.net/clever101 在xp系统上进行文件多选,实际上其文件字符串数组的缓冲区是有限,并不能支持选择任意多个文件,为此以前我还写过一篇文章: ...

  7. Ubuntu16.04+Gnome3 锁定屏幕快捷键无效解决办法

    Ubuntu16.04 桌面环境通过Ubuntu server和后安装的Gnome3 桌面环境实现,安装完以后发现锁定屏幕快捷键无效,系统设置=>键盘=>快捷中 锁屏快捷键已经存在Supe ...

  8. ES6学习笔记(二)变量的解构与赋值

    1.数组的解构赋值 1.1基本用法 ES6 允许按照一定模式,从数组和对象中提取值,对变量进行赋值,这被称为解构(Destructuring). 以前,为变量赋值,只能直接指定值. let a = 1 ...

  9. 【Docker构建私有仓库】

    Docker默认不允许非HTTPS方式推送镜像,我们可以通过Docker的配置选项来取消此限制: [root@fedora ~]# cat /etc/docker/daemon.json { &quo ...

  10. 数据持久化-存取方式总结&应用沙盒&文件管理NSFileManager

    iOS应用数据存储的常用方式:  1.XML属性列表   (plist归档)  2.NSUserDefaults (偏好设置)  3.NSKeyedArchiver  归档(加密形式)  4.SQLi ...