题意:凸包周长+一个完整的圆周长。因为走一圈,经过拐点时,所形成的扇形的内角和是360度,故一个完整的圆。

模板题,之前写的Graham模板不对,WR了很多发。。。。POJ上的AC代码

 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<set>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define clc(a,b) memset(a,b,sizeof(a))
#define eps 1e-8
#define PI acos(-1.0)
typedef long long LL;
const int mod=;
const int inf=0x3f3f3f3f;
const int MAXN=;
using namespace std; const int N = ; int top;
struct point
{
double x;
double y;
} p[N], Stack[N]; double dis(point A, point B)
{
return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
} double crossProd(point A, point B, point C)
{
return (B.x-A.x)*(C.y-A.y) - (B.y-A.y)*(C.x-A.x);
} int cmp(const void *a, const void *b)
{
point *c = (point *)a;
point *d = (point *)b;
double k = crossProd(p[], *c, *d);
if (k< || !k && dis(p[], *c)>dis(p[], *d))
return ;
return -;
} void Graham(int n)
{
double x = p[].x;
double y = p[].y;
int mi = ;
for (int i=; i<n; ++i)
{
if (p[i].x<x || (p[i].x==x && p[i].y<y))
{
x = p[i].x;
y = p[i].y;
mi = i;
}
}
point tmp = p[mi];
p[mi] = p[];
p[] = tmp;
qsort(p+, n-, sizeof(point), cmp);
p[n] = p[];
Stack[] = p[];
Stack[] = p[];
Stack[] = p[];
top = ;
for (int i=; i<=n; ++i)
{
while (crossProd(Stack[top-], Stack[top], p[i])<= && top>=) --top;
Stack[++top] = p[i];
}
} int main()
{
int n, l;
while (scanf("%d%d", &n, &l) != EOF)
{
for (int i=; i<n; ++i)
{
scanf ("%lf%lf", &p[i].x, &p[i].y);
}
Graham(n);
double ans=;
for(int i=;i<top;i++)
{
ans+=dis(Stack[i], Stack[i+]);
}
ans += PI * (l + l);
printf ("%d\n", (int)(ans+0.5));
}
return ;
}

POJ 1113&&HDU 1348的更多相关文章

  1. POJ 1113 || HDU 1348: wall(凸包问题)

    传送门: POJ:点击打开链接 HDU:点击打开链接 以下是POJ上的题: Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissio ...

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

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

  3. 计算几何--求凸包模板--Graham算法--poj 1113

    Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 28157   Accepted: 9401 Description ...

  4. POJ 2104&HDU 2665 Kth number(主席树入门+离散化)

    K-th Number Time Limit: 20000MS   Memory Limit: 65536K Total Submissions: 50247   Accepted: 17101 Ca ...

  5. poj 1113 凸包周长

    Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 33888   Accepted: 11544 Descriptio ...

  6. poj 1251 poj 1258 hdu 1863 poj 1287 poj 2421 hdu 1233 最小生成树模板题

    poj 1251  && hdu 1301 Sample Input 9 //n 结点数A 2 B 12 I 25B 3 C 10 H 40 I 8C 2 D 18 G 55D 1 E ...

  7. POJ 1113 Wall 凸包 裸

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

  8. poj 1113 Wall 凸包的应用

    题目链接:poj 1113   单调链凸包小结 题解:本题用到的依然是凸包来求,最短的周长,只是多加了一个圆的长度而已,套用模板,就能搞定: AC代码: #include<iostream> ...

  9. Eight POJ - 1077 HDU - 1043 八数码

    Eight POJ - 1077 HDU - 1043 八数码问题.用hash(康托展开)判重 bfs(TLE) #include<cstdio> #include<iostream ...

随机推荐

  1. OpenSSL重大漏洞-Heartbleed之漏洞利用脚本POC讲解

    OpenSSL Security Advisory [07 Apr 2014] ======================================== TLS heartbeat read ...

  2. 快速配置Ehcache

    1. 编写ehcache.xml文件,将该文件放置于classpath路径下.代码如下: <?xml version="1.0" encoding="UTF-8&q ...

  3. 如何设置Samza的metrics

    参考这个里边对API的调用 http://samza.incubator.apache.org/learn/documentation/0.7.0/container/metrics.html 参考这 ...

  4. Kafka 之 async producer (1)

    问题 很多条消息是怎么打包在一起的? 如果消息是发给很多不同的topic的, async producer如何在按batch发送的同时区分topic的 它是如何用key来做partition的? 是如 ...

  5. cannot find w3wp.exe in VS

    Same thing was happening to me, when i remembered that IIS has an idle timeout! As above the proc w3 ...

  6. 在WIN32 DLL中使用MFC库遇到的问题

    今天写了一个DLL,DLL中用到的一个类里用到的MSXML的COM组件,所以在DLL中要包含afx.h头文件,也就不可避免的要用到MFC的类库了,但在编译时出现了错误:mfcs42d.lib(dllm ...

  7. Ubuntu环境下手动配置Hadoop1.2.1

    /×××××××××××××××××××××××××××××××××××××××××/ Author:xxx0624 HomePage:http://www.cnblogs.com/xxx0624/ ...

  8. IText 生成简单表格(报表)doc文档 单元居中

    IText生成doc文档需要三个包:iTextAsian.jar,iText-rtf-2.1.4.jar,iText-2.1.4.jar 亲测无误,代码如下所示: import com.lowagie ...

  9. tomcat context 配置 项目部署

    将tomcat/conf/server.xml文件打开, 在</Host>标签之前添加: <Context path = "" docBase = "F ...

  10. HeadFirst设计模式之门面模式

    一. 1.The Facade Pattern provides a unifi ed interface to a set of interfaces in a subsytem. Facade d ...