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

题目大意:现在要给n个点,让你修一个围墙把这些点围起来,距离最小是l

分析  :现在就是求凸包的周长然后再加上一个圆的周长

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<queue> using namespace std;
#define N 1005
#define pi acos(-1.0)
#define ESP 1e-8 int s[N]; struct Point
{
double x,y;
Point(double x=,double y=):x(x),y(y){}
Point operator - (const Point &temp)const
{
return Point(x-temp.x,y-temp.y);
}
Point operator + (const Point &temp)const
{
return Point(x+temp.x,y+temp.y);
}
bool operator == (const Point &temp)const
{
return (x==temp.x && y==temp.y);
}
double operator * (const Point &temp)const
{
return (x*temp.x+y*temp.y);
}
int operator ^ (const Point &temp)const{
double t=x*temp.y-y*temp.x;
if(t>ESP)
return ;
if(fabs(t)<ESP)
return ;
return -;
}
}a[N]; double dist(Point a,Point b)
{
return sqrt((a-b)*(a-b));
} int cmp(Point a1,Point a2)
{
int t=((a1-a[])^(a2-a[]));
if(t==)
return dist(a1,a[])<dist(a2,a[]);
else
return t>;
}
int top;
void Graham(int n)///求凸包
{
s[]=;
s[]=;
top=;
for(int i=;i<n;i++)
{
while(top> && ((a[i]-a[s[top]])^(a[s[top-]]-a[s[top]]))<=)
top--;
s[++top]=i;
} } int main()
{
int n,l;
while(scanf("%d %d",&n,&l)!=EOF)
{
memset(s,,sizeof(s));
int k=;
for(int i=;i<n;i++)
{
scanf("%lf %lf",&a[i].x,&a[i].y);
if(a[i].y<a[k].y || (a[i].y==a[k].y && a[i].x<a[k].x))
k=i;
}
swap(a[],a[k]);
sort(a+,a+n,cmp); Graham(n);
double C=;
for(int i=;i<=top;i++)
{
C+=dist(a[s[i]],a[s[i-]]);
}
C+=dist(a[s[]],a[s[top]]);
C+=*pi*l;
printf("%.0lf\n",C);
}
return ;
}

Wall--POJ1113(极角排序+求凸包)的更多相关文章

  1. poj 1113:Wall(计算几何,求凸包周长)

    Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 28462   Accepted: 9498 Description ...

  2. L3-021 神坛(极角排序求三角形最小面积)

    在古老的迈瑞城,巍然屹立着 n 块神石.长老们商议,选取 3 块神石围成一个神坛.因为神坛的能量强度与它的面积成反比,因此神坛的面积越小越好.特殊地,如果有两块神石坐标相同,或者三块神石共线,神坛的面 ...

  3. hdu 1348:Wall(计算几何,求凸包周长)

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

  4. Wall - POJ 1113(求凸包)

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

  5. poj 1696 极角排序求最长逆时针螺旋线

    Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4970   Accepted: 3100 Descrip ...

  6. hdu5785(极角排序求所有锐角钝角个数)

    做法很显然,求出所有的锐角和钝角就能求出有多少个锐角三角形了. 我用了愚钝的方法,写了两三个小时... 看了下别人简单的代码.学习了下做法. sort(temp+,temp+cnt+);//排序 Fo ...

  7. 简单几何(极角排序) POJ 2007 Scrambled Polygon

    题目传送门 题意:裸的对原点的极角排序,凸包貌似不行. /************************************************ * Author :Running_Time ...

  8. poj 2187:Beauty Contest(计算几何,求凸包,最远点对)

    Beauty Contest Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 26180   Accepted: 8081 D ...

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

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

随机推荐

  1. Linux 服务器的网络配置 - 1. 查看 Linux 服务器的网络连接

    1. 查看 Linux 服务器的网络连接 1)查看主机名: liuqian@ubuntu:~$ hostname ubuntu 2)查看 ip 地址: 用 ifconfig 即可,这里介绍命令组合用法 ...

  2. Highcharts——大气好用的图标制作工具

    Highcharts是一款纯javascript编写的图表库,能够很简单便捷的在Web网站或Web应用中添加交互性的图表,Highcharts目前支持直线图.曲线图.面积图.柱状图.饼图.散点图等多达 ...

  3. Biological Filtration

    http://www.fishyou.com/filtration-biological.php Biological Filtration Biological filtration is the ...

  4. path和classpath

    对于Java的初学者,这两个环境变量,总是要遇到的.这里做一下总结. 1.path和classpath的含义 path是Windows操作系统的一个环境变量. 当操作系统需要运行一个程序,它需要知道该 ...

  5. JQ怎么获取margin-left的值

    var margin =$("#Modules .list").css('marginLeft');

  6. PHP常见方法

    1.获取字符串长度: preg_match_all('/./us', $only, $match); echo count($match[0]); 2.Php除法取整 2.1.round — 对浮点数 ...

  7. 什么是Mbps、Kbps、bps、kb、mb及其换算和区别

    Mbps 即 Milionbit pro second(百万位每秒): Kbps 即 Kilobit pro second(千位每秒): bps 即 bit pro second(位每秒): 速度单位 ...

  8. 使用jna调用dll,jdk位数和dll位数的关系

    最近在学习jna,发现dll文件能能否成功调用取决于jdk位数. 32位jdk只能使用32位的dll,64位jdk只能使用64位的dll,否则位数不对应的话报的错是 "Exception i ...

  9. TListView的一些操作

    1,让滚动条滚动的API SetScrollPos int SetScrollPos(     _In_  HWND hWnd,     _In_  int nBar,     _In_  int n ...

  10. IMoniker接口的MKParseDisplayName和 GetDisplayName的注意事项

    IMoniker接口的MKParseDisplayName和 GetDisplayName的注意事项