这道题是水题,发现平移某些边,答案就是圆心的凸包+一个圆的周长。

  不要忽视精度误差!

 #include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
const int N=;
const double eps=1e-;
const double Pi=acos(-1.0);
int sgn(double x){
if(x>eps)return ;
if(x<-eps)return -;
return ;
}
struct Point{
double x,y;
Point(double _=,double __=){x=_;y=__;}
friend Point operator+(Point a,Point b){
return Point(a.x+b.x,a.y+b.y);
}
friend Point operator-(Point a,Point b){
return Point(a.x-b.x,a.y-b.y);
}
friend bool operator<(Point a,Point b){
return sgn(a.y-b.y)?sgn(b.y-a.y)>:sgn(b.x-a.x)>;
}
}st[*N],p[*N];
double Cross(Point a,Point b){
return a.x*b.y-a.y*b.x;
} Point Rotate(Point a,double th){
double s=sin(th),c=cos(th);
return Point(a.x*c-a.y*s,a.x*s+a.y*c);
} double sqr(double x){return x*x;}
double Dis(Point a,Point b){
return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));
} bool cmp(Point a,Point b){
double c=Cross(a-p[],b-p[]);
if(sgn(c)>)return true;
if(sgn(c)<)return false;
return sgn(Dis(p[],b)-Dis(p[],a))>;
} double a,b,r;
double x,y,th;
int n,pos,top,tot;
int main(){
freopen("card.in","r",stdin);
freopen("card.out","w",stdout);
scanf("%d",&n);
scanf("%lf%lf%lf",&b,&a,&r);
a=a/2.0;a=a-r;b=b/2.0;b=b-r;
for(int i=;i<=n;i++){
scanf("%lf%lf%lf",&x,&y,&th);
Point O(x,y);
p[i*-]=Rotate(Point(x+a,y+b)-O,th)+O;
p[i*-]=Rotate(Point(x+a,y-b)-O,th)+O;
p[i*-]=Rotate(Point(x-a,y+b)-O,th)+O;
p[i*-]=Rotate(Point(x-a,y-b)-O,th)+O;
}
sort(p,p+*n);
for(int i=;i<*n;i++){
if(i==)p[tot++]=p[i];
else if(sgn(p[i].x-p[i-].x)||sgn(p[i].y-p[i-].y))
p[tot++]=p[i];
}
sort(p+,p+tot,cmp);p[tot]=p[];
st[]=p[];st[]=p[];top=;
for(int i=;i<=tot;i++){
while(top>=&&sgn(Cross(st[top]-p[i],st[top-]-p[i]))>=)top--;
st[++top]=p[i];
}
double ans=2.0*Pi*r;
for(int i=;i<=top;i++)
ans+=Dis(st[i],st[i-]);
printf("%.2f\n",ans);
return ;
}

计算几何(凸包):SHTSC 2012 信用卡凸包的更多相关文章

  1. 【计算几何】【凸包】bzoj2829 信用卡凸包

    http://hzwer.com/6330.html #include<cstdio> #include<cmath> #include<algorithm> us ...

  2. 【BZOJ 2829】 2829: 信用卡凸包 (凸包)

    2829: 信用卡凸包 Description Input Output Sample Input 2 6.0 2.0 0.0 0.0 0.0 0.0 2.0 -2.0 1.5707963268 Sa ...

  3. bzoj 2829 信用卡凸包(凸包)

    2829: 信用卡凸包 Time Limit: 10 Sec  Memory Limit: 128 MB Submit: 1342  Solved: 577 [Submit][Status][Disc ...

  4. 【BZOJ2829】[SHOI2012]信用卡凸包(凸包)

    [BZOJ2829][SHOI2012]信用卡凸包(凸包) 题面 BZOJ 洛谷 题解 既然圆角的半径都是一样的,而凸包的内角和恰好为\(360°\),所以只需要把圆角的圆心弄下来跑一个凸包,再额外加 ...

  5. Luogu-3829 [SHOI2012]信用卡凸包

    这道题的转化很巧妙,可以把信用卡四个角的圆心看做平面上的点来做凸包,\(ans\)就是凸包周长加上一个圆的周长 // luogu-judger-enable-o2 #include<cmath& ...

  6. [SHOI2012]信用卡凸包(凸包+直觉)

    这个题还是比较有趣. 小心发现,大胆猜想,不用证明! 我们发现所谓的信用卡凸包上弧的长度总和就是圆的周长! 然后再加上每个长宽都减去圆的直径之后的长方形的凸包周长即可! #include<ios ...

  7. [BZOJ2829] 信用卡 (凸包)

    [BZOJ2829] 信用卡 (凸包) 题面 信用卡是一个矩形,唯四个角做了圆滑处理,使他们都是与矩形两边相切的1/4园,如下图所示,现在平面上有一些规格相同的信用卡,试求其凸包的周长.注意凸包未必是 ...

  8. luogu P3829 [SHOI2012]信用卡凸包 凸包 点的旋转

    LINK:信用卡凸包 当 R==0的时候显然是一个点的旋转 之后再求凸包即可. 这里先说点如何旋转 如果是根据原点旋转的话 经过一个繁杂的推导可以得到一个矩阵. [cosw,-sinw] [sinw, ...

  9. 计算几何(一):凸包问题(Convex Hull)

    引言 首先介绍下什么是凸包?如下图: 在一个二维坐标系中,有若干点杂乱排列着,将最外层的点连接起来构成的凸多边型,它能包含给定的所有的点,这个多边形就是凸包. 实际上可以理解为用一个橡皮筋包含住所有给 ...

随机推荐

  1. iOS开发——文本高度

    1.简单的计算文本高度 // 要计算的文本内容 NSString *testString = @"刘成利,软件工程专业毕业,iOS开发者,目前工作于北京,在证券金融领域从事iOS App开发 ...

  2. Spring 对JDBC的支持(JdbcTemplate)

    Spring对数据库的操作,使用JdbcTemplate对象 需要引入相关的jar文件 如版本:(Spring核心jar包就不列了) spring-jdbc-3.2.5.RELEASE.jar spr ...

  3. 09.13日记(2014年9月13日00:18:26)英语,bootstrap,阮一峰,

    我们这里只推荐一本语法书:台湾的旋元佑老师写的<文法俱乐部>(简体版名为<语法俱乐部>).这本书因为出版社倒闭而绝版,淘宝可以买到影印的版本. (1)学英语:奶爸的英语教室 资 ...

  4. Cogs 1008. 贪婪大陆(树状数组)

    贪婪大陆 难度等级 ★★ 时间限制 1000 ms (1 s) 内存限制 128 MB 测试数据 10 简单对比 输入文件:greedisland.in 输出文件:greedisland.out 简单 ...

  5. Dynamic Programming: From novice to advanced

    作者:Dumitru 出处:http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=dynProg An impo ...

  6. RM-Linux驱动--Watch Dog Timer(看门狗)驱动分析

    from:http://blog.csdn.net/geekcome/article/details/6595265 硬件平台:FL2440 内核版本:2.6.28 主机平台:Ubuntu 11,04 ...

  7. 《sed的流艺术之三》-linux命令五分钟系列之二十三

    本原创文章属于<Linux大棚>博客,博客地址为http://roclinux.cn.文章作者为rocrocket. 为了防止某些网站的恶性转载,特在每篇文章前加入此信息,还望读者体谅. ...

  8. hadoop1——map到reduce中间的shuffle过程

    ---恢复内容开始--- shuffle和排序 过程图如下: MapReduce确保每个reduce的输入都按键排序,系统执行排序的过程——将map输出作为输入传给reduce——成为shuffle, ...

  9. poj 1144 Network

    Network 题意:输入n(n < 100)个点,不一定是连通图,问有多少个割点? 割点:删除某个点之后,图的联通分量增加. 思路:dfs利用时间戳dfs_clock的特性,点u的low函数l ...

  10. zend studio 9.0.4 安装破解

    转载于 http://www.geekso.com/ZendStudio9-key 注册破解步骤第一步:如果已经安装过Zend Studio 9.0.4的,请打开Zend Studio 9.0.4,在 ...