poj 1113
来源:互联网 发布:同花顺炒股票软件 编辑:程序博客网 时间:2024/06/06 13:14
凸包
至今还不知道这道题为什么凸包就是解,在网上搜结题报告也都是说求凸包,没告诉深层原因,求大神解答
#include <iostream>#include <cstdio>#include <algorithm>#include <math.h>using namespace std;const int maxn=1000+10;struct node{int x,y;};node point[maxn];int ch[maxn];int n,l;bool cmp(node a,node b){if(a.x<b.x) return true;else if(a.x==b.x) return a.y<b.y?true:false;else return false;}int cross(node a,node b,node c){return (b.x-a.x)*(c.y-b.y)-(b.y-a.y)*(c.x-b.x);}int Andrew(){sort(point,point+n,cmp);int m=0;int i;for(i=0;i<n;i++){while(m>1&&cross(point[ch[m-1]],point[ch[m-2]],point[i])<=0) m--;ch[m++]=i;}int k=m;for(i=n-2;i>=0;i--){while(m>k&&cross(point[ch[m-1]],point[ch[m-2]],point[i])<=0) m--;ch[m++]=i;}return m;}double dis(node a,node b){return sqrt(double((b.x-a.x)*(b.x-a.x)+(b.y-a.y)*(b.y-a.y)));}int main(){while(~scanf("%d%d",&n,&l)){int i;for(i=0;i<n;i++) scanf("%d%d",&point[i].x,&point[i].y);int tot=Andrew();double out=2*acos(-1.0)*l;for(i=0;i<tot-1;i++){out+=dis(point[ch[i]],point[ch[i+1]]);}printf("%.lf\n",out);}return 0;}
- poj 2365 poj 1113
- poj 1113
- POJ 1113
- poj 1113
- POJ 1113
- poj-1113
- poj 1113
- POJ 1113
- poj 1113
- POJ 1113
- poj 1113
- POJ 1113
- POJ 1113 WALL
- POJ 1113 Wall
- poj 1113 wall
- poj 1113 Wall
- POJ 1113 wall
- poj 1113 Wall
- Vector中add和addelement的区别
- 烟台大学CSDN俱乐部举办新浪微博(SAE云端开发)专题讲座
- 控制输入发窗口
- VS2010几个小技巧让你更加高效
- Linux下多定时器的实现
- poj 1113
- Codeforces Round #171 (Div. 2)(完全)
- Win7中删除移动盘上的某文件夹,结果无法删除,报错:您需要权限来执行此操作.您需要来自S-1-5-21-2212443540-3488208122-362533393-1000的权限才能对此文件夹进
- 烟台大学讲座:编程学习之路
- 堆、栈、静态区
- poj2031 最小生成树
- 键盘输入几个整数,求其乘积
- Linux 下 TCP IP 网络配置
- tomcat的端口修改