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

题意:给出一些点的坐标,和一个半径r,求出这些点围成的凸包的周长再加上一个半径为r的圆的周长。

 #include <stdio.h>
#include <algorithm>
#include <math.h>
const double PI=acos(-1.0);
const int N=;
using namespace std; struct Point
{
double x;
double y;
Point (double x = ,double y = ):x(x),y(y) {}
bool friend operator < (const Point &a, const Point &b)
{
return a.x < b.x||(a.x==b.x&&a.y < b.y);
}
} p[N],c[N];
typedef Point Vector;
double dis(Point A,Point B)//两点间的距离
{
return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}
Vector operator- (Point A,Point B)//求向量
{
return Vector(B.x-A.x,B.y-A.y);
}
double Cross(Vector A,Vector B)//求叉积
{
return A.x*B.y-A.y*B.x;
}
int ConvexHull(Point *p,int n,Point *c)//计算凸包
{
int k = ;
for (int i = ; i < n; i++)
{
while(k > && Cross(c[k-]-c[k-],c[k-]-p[i])<=)
k--;
c[k++] = p[i]; }
int m = k;
for (int i = n-; i >= ; i--)
{
while(k > m && Cross(c[k-]-c[k-],c[k-]-p[i])<=)
k--;
c[k++] = p[i];
}
c[k] = c[];
return k;
} int main()
{
int n;
double r;
scanf("%d %lf",&n,&r);
for (int i = ; i < n; i++)
scanf("%lf %lf",&p[i].x,&p[i].y);
sort(p,p+n);
int cnt = ConvexHull(p,n,c);
double len = ;
for (int i = ; i <= cnt; i++)
{
len+=dis(c[i],c[i-]);
}
len+=*PI*r;
printf("%.0f",len);
return ;
}

Wall(凸包)的更多相关文章

  1. hdu 1348 Wall (凸包)

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

  2. POJ 1113 Wall 凸包求周长

    Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 26286   Accepted: 8760 Description ...

  3. POJ1113 Wall —— 凸包

    题目链接:https://vjudge.net/problem/POJ-1113 Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submis ...

  4. POJ1113:Wall (凸包:求最小的多边形,到所有点的距离大于大于L)

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

  5. POJ1113:Wall (凸包算法学习)

    题意: 给你一个由n个点构成的多边形城堡(看成二维),按顺序给你n个点,相邻两个点相连. 让你围着这个多边形城堡建一个围墙,城堡任意一点到围墙的距离要求大于等于L,让你求这个围墙的最小周长(看成二维平 ...

  6. POJ 1113 - Wall 凸包

    此题为凸包问题模板题,题目中所给点均为整点,考虑到数据范围问题求norm()时先转换成double了,把norm()那句改成<vector>压栈即可求得凸包. 初次提交被坑得很惨,在GDB ...

  7. Wall(凸包POJ 1113)

    Wall Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 32360 Accepted: 10969 Description On ...

  8. POJ1113 Wall 凸包

    题目大意:建立围墙将城堡围起来,要求围墙至少距离城堡L,拐角处用圆弧取代,求围墙的长度. 题目思路:围墙长度=凸包周长+(2*PI*L),另外不知道为什么C++poj会RE,G++就没问题. #inc ...

  9. HDU1348 Wall 凸包

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1348 题意:给出一个凸包,求出与凸包距离 L的外圈周长 凸包模板题,练练Andrew算法求出凸包周长再 ...

  10. POJ 1113 Wall 凸包 裸

    LINK 题意:给出一个简单几何,问与其边距离长为L的几何图形的周长. 思路:求一个几何图形的最小外接几何,就是求凸包,距离为L相当于再多增加上一个圆的周长(因为只有四个角).看了黑书使用graham ...

随机推荐

  1. SqlServer 【基 本 操 作】

    1.Row_Number() select * from (select Row_Number() over (order by FSalary) as 'RowNum' ,* from dbo.T_ ...

  2. Linux内核中_IO,_IOR,_IOW,_IOWR宏的用法与解析

    ref from : http://blog.csdn.net/zhuxiaoping54532/article/details/49680537 main 在驱动程序里, ioctl() 函数上传送 ...

  3. CentOS 7.2安装配置Vsftp服务器

    一.配置防火墙,开启FTP服务器需要的端口 CentOS 7.2默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop fi ...

  4. 【codeforces 514A】Chewbaсca and Number

    [题目链接]:http://codeforces.com/contest/514/problem/A [题意] 允许你把每个数字翻转 ->x变成9-x 然后问你能够变成的最小的数字是什么; 不能 ...

  5. CodeForcesGym 100735D Triangle Formation

    Triangle Formation Time Limit: Unknown ms Memory Limit: 65536KB This problem will be judged on CodeF ...

  6. assertion: 18 { code: 18, ok: 0.0, errmsg: "auth fails" }

    MongoDB Version: 2.4.7 Mongodump: $ bin/mongodump -u admin -p admin -d test -o ./tmp/ connected to: ...

  7. [BZOJ 4999]This Problem Is Too Simple!

    [BZOJ 4999]This Problem Is Too Simple! 题目 给您一颗树,每个节点有个初始值. 现在支持以下两种操作: 1. C i x(0<=x<2^31) 表示将 ...

  8. Fibonacci数列(codevs 1250)

    题目描述 Description 定义:f0=f1=1, fn=fn-1+fn-2(n>=2).{fi}称为Fibonacci数列. 输入n,求fn mod q.其中1<=q<=30 ...

  9. JDK工具jstatd用法详解(转)

    jstatd,即虚拟机的jstat守护进程,主要用于监控JVM的创建与终止,并提供一个接口允许远程监控工具依附到在本地主机上运行的JVM. 用法摘要 jstatd [ options ] option ...

  10. N天学习一个linux命令之umask

    前言 umask不是linux命令,而是shell内置的指令,俗称用户权限掩码,用于对用户创建的文件和目录设置默认权限.默认的权限掩码是0022,也就是说新创建的文件权限是0644,新创建的目录权限是 ...