poj1113Wall
来源:互联网 发布:php 双向 加密 解密 编辑:程序博客网 时间:2024/06/05 22:48
#include <iostream>#include<cstdio>#include<algorithm>#include<vector>#include<cmath>#define PI 3.14159265358979323846using namespace std;const int MAX=1050;struct P{ int x,y; P() { } P(int x1,int y1) { x=x1; y=y1; } int det(P p) { return x*p.y-y*p.x; } int dot(P p) { return x*p.x + y*p.y; } P operator - (P p) { return P(x-p.x,y-p.y); }}p[MAX];bool cmp(const P& f,const P &s){ if(s.x!=f.x) return f.x<s.x; return f.y<s.y;}int n,l;vector<P> convex(){ int k=0; vector<P> q(2*n); for(int i=0;i<n;i++) { while(k>1&&(q[k-1]-q[k-2]).det(p[i]-q[k-1])<=0) k--; q[k++]=p[i]; } for(int i=n-2,t=k;i>=0;i--) { while(k>t&&(q[k-1]-q[k-2]).det(p[i]-q[k-1])<=0) k--; q[k++]=p[i]; } q.resize(k-1); return q;}double dis(P p, P q){ return sqrt((double)(p - q).dot(p - q));}int main(){ scanf("%d%d",&n,&l); for(int i=0;i<n;i++) scanf("%d%d",&p[i].x,&p[i].y); sort(p,p+n,cmp); vector<P> res=convex(); double ans=0; int num=res.size(); for(int i=0;i<num;i++) { ans+=dis(res[i],res[(i+1)%num]); } ans+=(2*PI*l); printf("%.0lf\n",ans); return 0;}
0 0
- poj1113Wall
- poj1113Wall
- poj1288poj1228Grandpa's Estate poj1113Wall
- poj1113Wall【凸包】
- POJ1113Wall(计算几何基础)
- 计算几何入门3--poj1113Wall
- poj1113Wall 求凸包周长 Graham扫描法
- poj1113Wall凸包入门题 模板
- poj1113Wall(凸包周长计算)
- 摊还分析
- JAVA通过JNI调用C++函数详解
- 面向对象的六大原则
- 手机网站的几点注意
- ubuntu使用命令行下载文件
- poj1113Wall
- Unity3d-向量Vector3
- UIImage设置渲染模式
- GitHub提交本地项目到服务器
- Ubuntu14.10安装goagent3.2.3
- UVA572 POJ1562 oil deposits(DFS求连通块问题)
- org.apache.jasper.JasperException错误
- 关于IDea的一些小事
- JAVA 对象引用,以及对象赋值