Time Limit: 10 Sec  Memory Limit: 128 MBSec  Special Judge
Submit: 333  Solved: 155

Description

Input

Output

Sample Input

2
6.0 2.0 0.0
0.0 0.0 0.0
2.0 -2.0 1.5707963268

Sample Output

21.66

HINT

本样例中的2张信用卡的轮廓在上图中用实线标出,如果视1.5707963268为

Pi/2(pi为圆周率),则其凸包的周长为16+4*sqrt(2)

Source

几何 凸包

把矩形边长减去圆的直径,得到有效边长。计算出每个矩形的四个点,找到凸包,再加上一个圆的周长就是答案。

迷之WA,注释掉的旋转方法不知为何不对(小样例居然都过了)

 /*by SilverN*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
const double Pi=acos(-1.0);
const int mxn=;
struct point{
double x,y;
point operator - (point rhs){return (point){x-rhs.x,y-rhs.y};}
point operator + (point rhs){return (point){x+rhs.x,y+rhs.y};}
}p[mxn]; double cross(point a,point b){return a.x*b.y-a.y*b.x;}
double dist(point a,point b){return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}
int cmp(point a,point b){
double tmp=cross(a-p[],b-p[]);
return (tmp< || (tmp== && dist(a,p[])>dist(b,p[])));
}
int cmp2(point a,point b,point p){
double tmp=cross(a-p,b-p);
return (tmp< || (tmp== && dist(a,p)>=dist(b,p)));
}
point rotate(point a,double angle){
return (point){a.x*cos(angle)-a.y*sin(angle),a.x*sin(angle)+a.y*cos(angle)};
}
point move(point a,double len,double an){
return (point){a.x+len*cos(an),a.y+len*sin(an)};
}
int n;
double a,b,r;
double x,y,th;
int st[mxn],top;
int main(){
int i,j;
scanf("%d",&n);
scanf("%lf%lf%lf",&a,&b,&r);
a-=*r;b-=*r;
top=;
for(i=;i<=n;i++){
scanf("%lf%lf%lf",&x,&y,&th);
for(j=;j<=;j++)
{
point tmp=move((point){x,y},b/,th+Pi*(j-)/);
p[++top]=move(tmp,a/,th+Pi*j/);
swap(a,b);
}
// point tmp;
/*
tmp.x=a/2;tmp.y=b/2;p[++top]=(point){x,y}+rotate(tmp,th);
tmp.x=-a/2;tmp.y=b/2;p[++top]=(point){x,y}+rotate(tmp,th);
tmp.x=a/2;tmp.y=-b/2;p[++top]=(point){x,y}+rotate(tmp,th);
tmp.x=-a/2;tmp.y=-b/2;p[++top]=(point){x,y}+rotate(tmp,th);
*/
}
n=top;top=;
int s=;
for(i=;i<=n;i++){
if(p[i].x<p[s].x || (p[i].x==p[s].x && p[i].y<p[s].y))s=i;
}
swap(p[s],p[]);
sort(p+,p+n+,cmp);
p[n+]=p[];
n++;
for(i=;i<=n;i++){
while(top> && cmp2(p[i],p[st[top]],p[st[top-]]))top--;
st[++top]=i;
}
double ans=;
ans+=Pi**r;
for(i=;i<top;i++){
ans+=sqrt(dist(p[st[i]],p[st[i+]]));
}
printf("%.2lf\n",ans);
return ;
}
/*
5
12.0 6.0 2.0
0.0 0.0 0.0
1 1 1
2 2 1.5707963268
1 7 0
2.0 -2.0 1.5707963268
*/

最新文章

  1. WebServices(转)
  2. python第十七天-----Django初体验
  3. 各大互联网公司前端面试题(js)
  4. Angularjs,WebAPI 搭建一个简易权限管理系统 —— 基本功能演示(二)
  5. java 实例之杨辉三角
  6. poj 3414 Pots ( bfs )
  7. jquery ajax 报交请求返回 HTTP 400 错误
  8. QQ情侣头像~
  9. vmware tools 安装
  10. 前端开发——移动bug整理
  11. arcengine 开发经典帖
  12. js原生设计模式——7原型模式之真正的原型模式——对象复制封装
  13. selenium+谷歌无头浏览器爬取网易新闻国内板块
  14. jmeter5.1在windows(含插件安装)及linux环境下安装
  15. Android-简单总结一下图片压缩
  16. Web APi入门之Self-Host寄宿及路由原理
  17. 如何配置使用HTML在线编辑工具
  18. Django中ORM介绍和字段及字段参数 Object Relational Mapping(ORM)
  19. Android开发常见错误汇总
  20. js关于去重的写法

热门文章

  1. 使用vscode开发vue cli 3项目,配置eslint以及prettier
  2. js跨域及解决办法
  3. java util - base64转换工具
  4. PHP 二维数组某个字段进行排序
  5. Android Studio 安装与使用ADB wifi 无线调试
  6. 大数据小项目之电视收视率企业项目08--》MapReduce编写之Wordcount
  7. 数据分析处理库Pandas——索引
  8. GoF23种设计模式之创建型模式之抽象工厂模式
  9. Python 列表元素分组,比如 [1,2,3,...20]变成 [[1,2,3],[4,5,6]....](列表生成式解决)
  10. P3805 【模版】manacher算法(manacher)