http://acm.hdu.edu.cn/showproblem.php?pid=1348

造城墙问题,求出凸包加上一圈圆的周长即可

凸包模板题

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define clr0(x) memset(x,0,sizeof(x))
#define eps 1e-9
const double pi = acos(-1.0);
typedef long long LL;
const int modo = 1e9 + 7;
const int maxn = 1e4 + 5;
struct point{
int x,y;
}a[maxn];
int b[maxn];
bool cmp(point a,point b)
{
return a.x < b.x || (a.x == b.x && a.y < b.y);
}
double dis(point a,point b)
{
return sqrt(double((a.x-b.x)*(a.x-b.x)) + double((a.y - b.y)*(a.y - b.y)));
}
int cj(point a,point b,point c)
{
return (a.x - c.x) * (b.y - c.y) - (a.y - c.y) *(b.x - c.x);
}
int m;
void graham(int n)
{
sort(a,a+n,cmp);
b[0] = 0,b[1] = 1,b[2] = 2;
int k = 1;
for(int i = 2;i < n;++i){
while(k && cj(a[i],a[b[k]],a[b[k-1]]) >= 0)
--k;
b[++k] = i;
}
m = k;
b[++k] = n - 2;
for(int i = n - 3;i >= 0;--i){
while(k != m && cj(a[i],a[b[k]],a[b[k-1]]) >= 0)
--k;
b[++k] = i;
}
m = k;
}
int main() {
int n,_;double f;
RD(_);
while(_--){
RD(n);
scanf("%lf",&f);
for(int i = 0;i < n;++i){
RD2(a[i].x,a[i].y);
}
graham(n);
double ans = 0;
for(int i = 0;i < m;++i)
ans += dis(a[b[i]],a[b[i+1]]);
ans += dis(a[b[m]],a[b[0]]);
ans += pi * 2 *f;
printf("%.0lf\n",ans);
if(_>0)
puts("");
}
return 0;
}

hdu 1348 凸包模板的更多相关文章

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

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

  2. hdu 1348(凸包)

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

  3. hdu 1348 Wall (凸包)

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

  4. 计算几何(凸包模板):HDU 1392 Surround the Trees

    There are a lot of trees in an area. A peasant wants to buy a rope to surround all these trees. So a ...

  5. hdu 2202 最大三角形_凸包模板

    题意:略 思路:直接套用凸包模板 #include <iostream> #include <cstdio> #include <cmath> #include & ...

  6. hdu 1686 KMP模板

    // hdu 1686 KMP模板 // 没啥好说的,KMP裸题,这里是MP模板 #include <cstdio> #include <iostream> #include ...

  7. HDU 1392 凸包

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

  8. 凸包模板 POJ1873

    // 凸包模板 POJ1873 // n=15所以可以按位枚举求凸包,再记录数据 #include <iostream> #include <cstdio> #include ...

  9. HDU 4946 凸包

    给你n个点,具有速度,一个位置如果有其他点能够先到,则不能继续访问,求出里面这些点哪些点是能够无限移动的. 首先我们考虑到,一个速度小的和一个速度大的,速度小的必定只有固定他周围的一定区域是它先到的, ...

随机推荐

  1. 吴裕雄 实战python编程(1)

    import sqlite3 conn = sqlite3.connect('E:\\test.sqlite') # 建立数据库联接cursor = conn.cursor() # 建立 cursor ...

  2. Mysql一些记忆

    mysql修改密码报错是yum 安装mysql5.7 是 出现无法登陆问题以及mysql error You must reset your password using ALTER USER sta ...

  3. Python 遍历文件夹 listdir walk 的区别

    一.一级目录import os path = 'd:\file'; for filename in os.listdir(path): print(os.path.join(path,filename ...

  4. zg项目 应用系统编码原则

    一.编码说明: 1.系统编码采用三码为原则,通常两码简称之. 1>.子系统或类型 2>.系统小分类 3>.系统大分类 如 IPMS领域业务群: DA 应用软件发展管理系统 DE公用副 ...

  5. 将2020年交期的PR回写出来了

    OUT_pr表中的交期为2020年和2019年,不应该 回写的PR却回写出来了 优化如下:

  6. [leetcode]496. Next Greater Element I下一个较大元素

    You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of n ...

  7. sublime text3 配置

    1.在sublime text官网下载安装文件并安装 http://www.sublimetext.com/ 2.安装sublime的package control 参考网址:https://pack ...

  8. vim之quickfix

    [vim之quickfix] quickfix功能将编译过程中产生的错误信息保存到文件中,然后vim利用这些信息跳转到源文件的对应位置,我们就可以进行错误的修正,之后跳到下一个错误重复上述操作,从而极 ...

  9. mysql水平分区

    解决问题:单表数据量过大 ALTER TABLE boc_url_log PARTITION BY RANGE (ulid) ( PARTITION log_1 VALUES LESS THAN () ...

  10. Vue.js2 + Laravel5 采用 CORS 方式解决 AJAX 跨域的问题

    一.建立中间件 php artisan make:middleware CorsAjax 二.编写中间件 CorsAjax <?phpnamespace App\Http\Middleware; ...