这个题还是比较有趣。

小心发现,大胆猜想,不用证明!

我们发现所谓的信用卡凸包上弧的长度总和就是圆的周长!

然后再加上每个长宽都减去圆的直径之后的长方形的凸包周长即可!

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=40100;
const double eps=1e-12;
int stack[N],top,n;
double a,b,r,ans;
struct node{
double x,y;
node(double xx=0,double yy=0){
x=xx;y=yy;
}
}c[N];
node work(node a,double x){
double A=cos(x),B=sin(x);
return node(a.x*A-a.y*B,a.x*B+a.y*A);
}
bool cmp(node a,node b){
if(a.x==b.x)return a.y<b.y;
else return a.x<b.x;
}
double chaji(node a,node b){
return a.x*b.y-a.y*b.x;
}
node operator -(node a,node b){
return node(a.x-b.x,a.y-b.y);
}
node operator +(node a,node b){
return node(a.x+b.x,a.y+b.y);
}
double dis(node a,node b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int main(){
scanf("%d",&n);
scanf("%lf%lf%lf",&a,&b,&r);
a-=2.0*r;b-=2.0*r;
ans=acos(-1.0)*r*2.0;
for(int i=0;i<n;i++){
double x,y,z;
scanf("%lf%lf%lf",&x,&y,&z);
c[i*4+1].x=b/2.0;c[i*4+1].y=a/2.0;
c[i*4+1]=work(c[i*4+1],z);c[i*4+1].x+=x;c[i*4+1].y+=y;
c[i*4+2].x=-b/2.0;c[i*4+2].y=a/2.0;
c[i*4+2]=work(c[i*4+2],z);c[i*4+2].x+=x;c[i*4+2].y+=y;
c[i*4+3].x=b/2.0;c[i*4+3].y=-a/2.0;
c[i*4+3]=work(c[i*4+3],z);c[i*4+3].x+=x;c[i*4+3].y+=y;
c[i*4+4].x=-b/2.0;c[i*4+4].y=-a/2.0;
c[i*4+4]=work(c[i*4+4],z);c[i*4+4].x+=x;c[i*4+4].y+=y;
}
sort(c+1,c+1+n*4,cmp);
for(int i=1;i<=n*4;i++){
if(top<=1){stack[++top]=i;continue;}
while(top>=2&&chaji(c[stack[top]]-c[stack[top-1]],c[i]-c[stack[top]])+eps<0)top--;
stack[++top]=i;
}
for(int i=1;i<top;i++)ans+=dis(c[stack[i]],c[stack[i+1]]);
top=0;
for(int i=n*4;i>=1;i--){
if(top<=1){stack[++top]=i;continue;}
while(top>=2&&chaji(c[stack[top]]-c[stack[top-1]],c[i]-c[stack[top]])+eps<0)top--;
stack[++top]=i;
}
for(int i=1;i<top;i++)ans+=dis(c[stack[i]],c[stack[i+1]]);
printf("%.2lf",ans);
return 0;
}

最新文章

  1. Unable to create the selected property page. An error occurred while automatically activating bundle net.sourceforge.pmd
  2. angularjs中的filter(过滤器)——格式化日期的date
  3. Android 热修复,插件式开发---基本知识
  4. css的小问题总结
  5. Postgresql 帐号密码修改方法
  6. android res文件夹下面的 values-v11 、 values-v14
  7. 内存恶鬼drawRect
  8. iOS 获取设备型号以及IP地址
  9. 深入剖析keil c51 --- 从汇编到c51
  10. 博弈论(Game Theory) - 01 - 前传之占优战略均衡
  11. 在tomcat7中启用HTTPS的详细配置
  12. [LeetCode] Number of Atoms 原子的个数
  13. ThetaSome_ThetaAll子查询
  14. 如何添加使用echats地图悬浮显示内容
  15. maven打包不包含配置文件[z]
  16. SQL Data Compare 对比 SQLserver数据
  17. tomcat部署项目(war文件)
  18. jQuery实用Demo
  19. tesseract-ocr识别中文扫描图片实例讲解
  20. SQL 正则表达式 `(user_log_acct)?+.+`

热门文章

  1. 0918如何利用jmeter为数据库插入测试数据
  2. Codeforces 474 C. Captain Marmot
  3. linux 线程切换效率与进程切换效率相差究竟有多大?
  4. HDU 2604 Queuing,矩阵高速幂
  5. Hadoop Web项目--Friend Find系统
  6. c17---指针
  7. 【BZOJ1565】【NOI2009】植物大战僵尸
  8. SwiftUI 官方教程
  9. putty和xshell使用和免密登录
  10. BZOJ 1531 二进制优化多重背包