#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扫描法的更多相关文章

  1. POJ 1113 Wall(Graham求凸包周长)

    题目链接 题意 : 求凸包周长+一个完整的圆周长. 因为走一圈,经过拐点时,所形成的扇形的内角和是360度,故一个完整的圆. 思路 : 求出凸包来,然后加上圆的周长 #include <stdi ...

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

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

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

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

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

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

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

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

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

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

  7. 凸包模板——Graham扫描法

    凸包模板--Graham扫描法 First 标签: 数学方法--计算几何 题目:洛谷P2742[模板]二维凸包/[USACO5.1]圈奶牛Fencing the Cows yyb的讲解:https:/ ...

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

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

  9. poj1873(二进制枚举+求凸包周长)

    题目链接:https://vjudge.net/problem/POJ-1873 题意:n个点(2<=n<=15),给出n个点的坐标(x,y).价值v.做篱笆时的长度l,求选择哪些点来做篱 ...

随机推荐

  1. hdu 5174(计数)

    Ferries Wheel Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tot ...

  2. hdu 1224(动态规划 DAG上的最长路)

    Free DIY Tour Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  3. JSONObject依赖包

    commons-lang.jar commons-beanutils.jar commons-collections.jar commons-logging.jar ezmorph.jar json- ...

  4. 【互动问答分享】第5期决胜云计算大数据时代Spark亚太研究院公益大讲堂

    Spark亚太研究院100期公益大讲堂 [第5期互动问答分享] Q1:spark怎样支持即席,应该不是spark sql吧,是hive on spark么? Spark1.0 以前支持即席查询的技术是 ...

  5. BZOJ 1008: [HNOI2008]越狱-快速幂/取模

    1008: [HNOI2008]越狱 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 8689  Solved: 3748 Description 监狱有 ...

  6. flutter 频道切换

    https://github.com/flutter/flutter/wiki/Flutter-build-release-channels 频道说明页 https://flutter.dev/doc ...

  7. Verify Preorder Serialization of a Binary Tree -- LeetCode

    One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, ...

  8. Scala实战高手****第14课:Scala集合上的函数式编程实战及Spark源码鉴赏

    package com.dt.spark.scala.bascis object Functional_Itearal {   def main(args: Array[String]): Unit ...

  9. 图像视图-ImageView

    (一) 知识点: (1)imageView.setImageAlpha(Alpha):设置图片透明度 (2)在布局imageView中设置图片位置:android:scaleType="ce ...

  10. javascript 定时器 笔记

    最近想看下定时器,发现这东西越看越牵连的东西越多,比如js单线程,EVent loop 什么的 看到了几篇比较好的文章 http://ejohn.org/blog/how-javascript-tim ...