题目链接

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

因为走一圈,经过拐点时,所形成的扇形的内角和是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. 通过store为toolbar添加按钮

    目的是实现导航条toolbar可以动态加载按钮. ExtJS的版本是4.0. 实现方案有两个.方案一:添加render事件监听,在监听事件处理函数中使用Ext.Ajax获取按钮信息,实现动态添加按钮. ...

  2. 高德地图JavaScript API开发研究

    高德地图JavaScript API是一套用JavaScript 语言编写的应用程序接口,可以通过各种API接口向地图添加内容,创建功能丰富.交互性强的地图应用.高德地图JavaScript API ...

  3. VBA 一些用法

    另存为txt格式: Sheets().Activate ActiveWorkbook.SaveAs Filename:="E:\etl_folder\", FileFormat:= ...

  4. 使用xilinx ip core FIFO First- World First-Through (FWFT)模式的注意事项

    也许很多人知道xilinx ip core 中的fifo可以配成standard 模式和FWFT模式,并知道两者的区别是:standard模式下,当rd为高时,fifo会延时一个时钟输出数据(时序逻辑 ...

  5. Leetcode-Construct Binary Tree from inorder and preorder travesal

    Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that ...

  6. 团队开发——第一篇scrum报告

    一.角色介绍 产品负责人(兼项目经理PM):王雪青 scrum master: 陆宇 开发团队:赵建松.张文冬.徐擎天 二.product backlog 1.买家登录后,显示各个小吃摊的信息,主要是 ...

  7. Mysql 导出数据库和指定表中的数据

    参考地址:http://jingyan.baidu.com/article/b7001fe14240ab0e7282dde9.html [root@youo zw]# mysqldump -u roo ...

  8. WebSocket学习

    在HTML5规范中,我最喜欢的Web技术就是正迅速变得流行的WebSocket API.WebSocket提供了一个受欢迎的技术,以替代我们过去几年一直在用的Ajax技术.这个新的API提供了一个方法 ...

  9. mysql 存储过程 -- 游标的使用(备忘)

    BEGIN ; DECLARE f_ratio FLOAT DEFAULT 0.8; ); ); DECLARE i_statDate DATE; DECLARE i_accumulateCount ...

  10. android开发 textview根据字数长度自动调整字体大小

    需求:根据输入的值实时显示到textview中预览,但是字体大小是要自动适配的 网上有一个代码,但是在我这里不能用,注意方法:refitText  注释掉的是之前的代码 import com.cars ...