题意:凸包周长+一个完整的圆周长。因为走一圈,经过拐点时,所形成的扇形的内角和是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. 返回canceled 代码 的原因

    ajax 不支持跨域操作jsonp,才导致返回canceled 代码. 解决的办法就是 <script>标签.jquery 也为我们提供了$.Ajax()方法或$.getScript()方 ...

  2. Binding to the Most Recent Visual Studio Libraries--说的很详细,很清楚

    Every version of Visual Studio comes with certain versions of the Microsoft libraries, such as the C ...

  3. linux usermod修改用户所在组方法

    usermod 用户名 -g 组名 -g<群组> 修改用户所属的群组. -G<群组> 修改用户所属的附加群组.

  4. windows 下 文件属性及目录列表操作

    转:http://blog.sina.com.cn/s/blog_686d0fb001012tsg.html 我们需要一个结构体和几个函数.这些函数和结构体在<io.h>的头文件中,结构体 ...

  5. Java API ——Character类

    1.Character类的概述 · Character 类在对象中包装一个基本类型 char 的值 · 此外,该类提供了几种方法,以确定字符的类别(小写字母,数字,等等),并将字符从大写转换成小写,反 ...

  6. JMS消息传输机制

    JMS消息传送模型: 消息传送机制, 是基于拉取(pull)或者轮询(polling)的方式.  JMS具备两种"消息传送模型": P2P和Pub/sub. (1) P2P:点对点 ...

  7. 使用PHP抓取网站ico图标

    网站许久没用更新,以后会经常更新,本次分享一个使用PHP抓取网站ico的程序,提供一个网站列表后对网站的ico进行下载抓取,具体代码如下: <?php /** * 更新热站ico * gao 2 ...

  8. 各开源协议BSD,GPL,LGPL,Apache 2.0,mit等简介*

    快速阅读 分类 子分类 开源约定 BSD original BSD license.FreeBSD license.Original BSD license 为所欲为 Apache Licence 2 ...

  9. String Split 和 Join

    很多时候处理字符串数据,比如从文件中读取或者存入 - 我们可能需要加入分隔符(如CSV文件中的逗号),或使用一个分隔符来合并字符串序列. 很多人都知道使用split()的方法,但使用与其对应的Join ...

  10. Android开发之点击两次Back键退出App

    Back按键的方法是onKeyDown()方法,重写该方法就可以改变back按键的作用. 实现点击两次Back按键退出app,有两种方法: 方法1. private static boolean is ...