poj 113——wall
来源:互联网 发布:淘宝样式管理 编辑:程序博客网 时间:2024/06/04 01:37
凸包
凸包长度+2*pi*r
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>using namespace std;#define eps (1e-8)#define pi acos(-1.0)struct point{double x,y;point(double x=0, double y=0) : x(x), y(y){}}p[1100],ans[1100];typedef point vector;point operator-(point a,point b) { return point(a.x-b.x, a.y-b.y);};int n;double r;double Len(point& a,point& b){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}inline int Sgn(double x) {return x < -eps ? -1 : x > eps ? 1 : 0;}bool Cmp(point& a,point& b){if(Sgn(a.x-b.x)==0)return a.y<b.y;elsereturn a.x<b.x;}int Cross(vector a,vector b){return Sgn(a.x*b.y-a.y*b.x);}int Andrew(){sort(p,p+n,Cmp);int m=0; //凸包上的点的个数 for(int i=0;i<n;i++) {while(m>1&&Cross(ans[m-1]-ans[m-2],p[i]-ans[m-2])<=0)m--;ans[m++]=p[i];}int k=m;for(int i=n-2;i>=0;i--){while(m>k&&Cross(ans[m-1]-ans[m-2],p[i]-ans[m-2])<=0)m--;ans[m++]=p[i];}if(n>1)m--;return m;}int main(){while(cin>>n>>r){for(int i=0;i<n;i++)scanf("%lf%lf",&p[i].x,&p[i].y);int m=Andrew();double dist=0.0;for(int i=0;i<m-1;i++)dist+=Len(ans[i],ans[i+1]);dist+=Len(ans[m-1],ans[0])+2*pi*r;printf("%d\n",(int)(dist+0.5));}return 0;}
- poj 113——wall
- POJ 1113——WALL
- Wall POJ
- poj1113——Wall
- POJ 1113 WALL
- POJ 1113 Wall
- poj 1113 wall
- poj 1113 Wall
- POJ 1113 wall
- poj 1131 wall
- poj 1113 Wall
- POJ 1113 WALL
- POJ 1113 Wall
- poj 1113 Wall
- POJ 1113 Wall
- poj 1113 Wall
- POJ 1113(Wall-Quickhull)
- POJ 1113 Wall
- 让DIV+CSS兼容所有浏览器
- C++的结构块中成员函数的使用
- hdu4730 We Love MOE Girls
- AAC专利介绍
- HDU4720几何性质
- poj 113——wall
- LCS(最长公共子列--动态规划)
- LIS最长递增子序列DPC++实现
- 高性能javascript
- paip.QQ音乐导出歌单总结
- 最长公共子序列和最长递增子序列
- 关于字符串指针不可修改的问题
- jquery-mvc中ajax重复提交(click重复绑定)以及点击没反应问题
- C/C++资源