题目链接

题意 : 求凸包周长+一个完整的圆周长。

因为走一圈,经过拐点时,所形成的扇形的内角和是360度,故一个完整的圆。

思路 : 求出凸包来,然后加上圆的周长

 #include <stdio.h>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm> const double PI = acos(-1.0) ;
using namespace std ; struct point
{
double x,y ;
}p[],p1[];
int n ,m; double dis(point a,point b)
{
return sqrt(double((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))) ;
}
double cross(point a,point b,point c)
{
return (a.x-c.x)*(b.y-c.y) - (a.y-c.y)*(b.x-c.x) ;
}
bool cmp(point a,point b)
{
if(cross(a,b,p[]) > || cross(a,b,p[]) == && dis(a,p[]) < dis(b,p[]))
return true ;
return false ;
}
void Graham()
{
int cnt;
sort(p+,p+n,cmp) ;
p[n] = p[] ;
p1[] = p[] ;
p1[] = p[] ;
cnt = ;
for(int i = ; i <= n ; i++)
{
while(cnt >= && cross(p1[cnt-],p1[cnt],p[i]) <= ) cnt -- ;
p1[ ++cnt] = p[i] ;
}
double sum = 0.0 ;
for(int i = ; i < cnt ; i++)
{
sum += dis(p1[i],p1[i+]) ;
}
printf("%.0lf\n",sum+*PI*m) ;
}
int main()
{
while(~scanf("%d %d",&n,&m))
{
int pos = ;
for(int i = ; i < n ; i++)
{
scanf("%lf %lf",&p[i].x,&p[i].y) ;
if(p[pos].y > p[i].y || (p[pos].y == p[i].y && p[i].x < p[pos].x))
pos = i ;
}
// if(n == 1) {puts("0.00");continue ;}
// if(n == 2)
// {
// printf("%.2lf\n",dis(p[1],p[0])) ;
// continue ;
// }
swap(p[pos],p[]) ;
//printf("%d %d\n",p[0].x,p[0].y) ;
Graham() ;
}
return ;
}

POJ 1113 Wall(Graham求凸包周长)的更多相关文章

  1. HDU 1392 Surround the Trees (Graham求凸包周长)

    题目链接 题意 : 让你找出最小的凸包周长 . 思路 : 用Graham求出凸包,然后对每条边求长即可. Graham详解 #include <stdio.h> #include < ...

  2. The Fortified Forest - POJ 1873(状态枚举+求凸包周长)

    题目大意:有个国王他有一片森林,现在他想从这个森林里面砍伐一些树木做成篱笆把剩下的树木围起来,已知每个树都有不同的价值还有高度,求出来砍掉那些树可以做成篱笆把剩余的树都围起来,要使砍伐的树木的价值最小 ...

  3. POJ 1113 Wall 凸包 裸

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

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

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

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

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

  6. POJ 1113 Wall (凸包)

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

  7. HDU 1392 凸包模板题,求凸包周长

    1.HDU 1392 Surround the Trees 2.题意:就是求凸包周长 3.总结:第一次做计算几何,没办法,还是看了大牛的博客 #include<iostream> #inc ...

  8. Wall---hdu1348(求凸包周长 模板)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1348 求凸包周长+2*PI*L: #include <stdio.h> #include ...

  9. hdu 1392:Surround the Trees(计算几何,求凸包周长)

    Surround the Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

随机推荐

  1. SQLite数据库与Contentprovider(2)

    ContentProvider: 在创建ContentProvider时,需要首先使用数据库.文件系统或网络实现底层存储功能, 然后在继承ContentProvider的类中实现基本数据操作的接口函数 ...

  2. hdu 3288 Resource Allocation

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=3288 Resource Allocation Description HDU-Sailormoon i ...

  3. 使用VMDepot镜像快速部署CKAN开放数据门户

    最新发布的CKAN VMDepot镜像针对中国用户强化了中文支持,提升了与MS Office办公软件的互操作性,并集成了常用插件和最佳实践配置参数. 使得CKAN原本十分复杂繁琐的部署流程变得非常简单 ...

  4. OpenStack的bridge_sto off的解释

    北京_张华(28620211) 2014/1/27 星期一 11:10:57传统的网络是通过STP协议来避免交换机在二层形成环路,但是对于虚拟交换机,因为有东西向的流量,故将bridge_stp设成o ...

  5. django-south

    python manage.py schemamigration youappname --initial # --initial在数据库创建models定义的表,以及South需要的south_mi ...

  6. Awesome Swift

    Awesome Swift https://github.com/matteocrippa/awesome-swift A collaborative list of awesome Swift re ...

  7. 上传图片的回调函数,callback作为一个函数针对回调函数

    Tool.ImageUpload = function (selector, callback) { /// <summary>图片上传</summary> /// <p ...

  8. Entity Framework学习笔记(一)

    请注明转载地址:http://www.cnblogs.com/arhat 哈哈!老魏回来了,4月份的内容开始更新了,由于3月份时间都在做项目,没有时间写了,那么4月份老魏会尽可能的多写点东西的.那么4 ...

  9. 64位Windows2003下如何正确发布VesnData.Net(VDN)

    64位windows2003下发布VDN,按照正常的步骤会出现:试图加载格式不正确的程序. (异常来自 HRESULT:0x8007000B)的错误. 按照下面的步骤进行处理: 1.如果安装了64位F ...

  10. MySQL 存储过程学习笔记

    存储过程框架 DEMILITER $$ -- 重定义符 DROP PROCEDURE IF EXISTS store_procedure$$ -- 如果存在此名的存储过程,先删除 CREATE PRO ...