poj1113Wall 求凸包周长 Graham扫描法
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef pair<int ,int > ll;
ll num,dot[1010];
int i;
const double pi=3.1415926535898;
ll operator -(ll a,ll b)
{
return make_pair(a.first-b.first,a.second-b.second);
}
bool cmp(ll a,ll b)
{
return (a.first!=b.first?a.first<b.first:a.second<b.second);
}
int cross(ll a,ll b)
{
return a.first*b.second-b.first*a.second;
}
int d2(ll a,ll b)
{
return (a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second);
}
double d1(ll a,ll b)
{
return sqrt((double)d2(a,b));
}
bool cmp1(ll a,ll b)
{
int r=cross(a-dot[0],b-dot[0]);
return (r!=0?r>0:d2(a,dot[0])<d2(b,dot[0]));
}
void in()
{
cin>>num.first>>num.second;
for(i=0;i<num.first;i++)
cin>>dot[i].first>>dot[i].second;
}
void work()
{
sort(dot,dot+num.first,cmp);
sort(dot,dot+num.first,cmp1); ll box[1010]={dot[0],dot[1]};
int tail=1;
for(i=2;i<num.first;)
{
if(cross(box[tail]-box[tail-1],dot[i]-box[tail-1])>=0)
box[++tail]=dot[i++];
else
tail--;
} double ans=d1(box[0],box[tail])+2*pi*num.second;
for(i=0;i<tail;i++)
ans+=d1(box[i],box[i+1]);
printf("%.0lf\n",ans);
}
int main()
{
in();
work();
}
poj1113Wall 求凸包周长 Graham扫描法的更多相关文章
- POJ 1113 Wall(Graham求凸包周长)
题目链接 题意 : 求凸包周长+一个完整的圆周长. 因为走一圈,经过拐点时,所形成的扇形的内角和是360度,故一个完整的圆. 思路 : 求出凸包来,然后加上圆的周长 #include <stdi ...
- HDU 1392 凸包模板题,求凸包周长
1.HDU 1392 Surround the Trees 2.题意:就是求凸包周长 3.总结:第一次做计算几何,没办法,还是看了大牛的博客 #include<iostream> #inc ...
- poj 1113:Wall(计算几何,求凸包周长)
Wall Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 28462 Accepted: 9498 Description ...
- Wall---hdu1348(求凸包周长 模板)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1348 求凸包周长+2*PI*L: #include <stdio.h> #include ...
- hdu 1392:Surround the Trees(计算几何,求凸包周长)
Surround the Trees Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- hdu 1348:Wall(计算几何,求凸包周长)
Wall Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- 凸包模板——Graham扫描法
凸包模板--Graham扫描法 First 标签: 数学方法--计算几何 题目:洛谷P2742[模板]二维凸包/[USACO5.1]圈奶牛Fencing the Cows yyb的讲解:https:/ ...
- HDU 1392 Surround the Trees (Graham求凸包周长)
题目链接 题意 : 让你找出最小的凸包周长 . 思路 : 用Graham求出凸包,然后对每条边求长即可. Graham详解 #include <stdio.h> #include < ...
- poj1873(二进制枚举+求凸包周长)
题目链接:https://vjudge.net/problem/POJ-1873 题意:n个点(2<=n<=15),给出n个点的坐标(x,y).价值v.做篱笆时的长度l,求选择哪些点来做篱 ...
随机推荐
- Docker Ubuntu容器安装ping(zz)
更新apt-get的软件包信息,然后再安装 sudo docker run ubuntu apt-get update sudo docker run ubuntu apt-get install i ...
- ros msg array
#include <stdio.h> #include <stdlib.h> #include "ros/ros.h" #include "std ...
- APP中常见上下循环滚动通知的简单实现,点击可进入详情
APP中常见上下循环滚动通知的简单实现,点击可进入详情 关注finddreams博客,一起分享一起进步!http://blog.csdn.net/finddreams/article/details/ ...
- 平滑部署war包到tomcat-deploy.sh
#!/bin/sh #check war exists echo "check war exists" war_file_path=/data/tomcat8/webapps wa ...
- 超越IEtab、网银支付助手,无需再次登陆的Firefox的IE插件
强烈推荐! fire-ie最大亮点就是:可以传递firefox下的cookie,从而避免了再次登陆或打开支付页面的繁琐. 在线安装:https://addons.mozilla.org/zh-CN/f ...
- owasp zap 安全审计工具 的fuzzer使用
owasp zap 安全审计工具 的fuzzer可用场景如下: 一.SQL注入和XSS攻击等 1.选中请求中需要检查的字段值,右键-Fuzzy 2.选中file fuzzer功能(包括SQL注入,xs ...
- MySql笔记之数据表
数据表:行称为记录 列称为字段 用来存储数据 一.数据类型 数据类型是指列.存储过程参数.表达式和局部变量的数据特征,它决定了数据的存储格式,代表了不同的信息类型. 在我们存储不同类型的数据时,为了 ...
- 用户点击行为实时分析系统spark
系统设计技术有:Hadoop2.xZookeeperFlumeHiveHbaseKafkaSpark2.xSpark StreamingStructured StreamingMySQLHueJava ...
- Windows 环境下 Redis 安装
1.redis官方下载地址:https://redis.io/download,redis 64位下载地址:https://github.com/MicrosoftArchive/redis/rele ...
- 免费Jdk选择:jdkadoptOpenJdk
oracle公司的jdk即将要收费,不在给免费用户提供更新,点击查看. jira在7.13版本将jdk从oracle jdk变更为adoptOpenJdk.点击查看.