bzoj2829 信用卡凸包
来源:互联网 发布:联想清灰软件 编辑:程序博客网 时间:2024/05/04 06:48
2829: 信用卡凸包
Time Limit: 10 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 226 Solved: 102
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
2
6.0 2.0 0.0
0.0 0.0 0.0
2.0 -2.0 1.5707963268
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)
凸包
将图形去掉外面一层,留下中间的矩形,求出凸包,最后加上一个圆的周长。
#include<iostream>#include<cstdlib>#include<cmath>#include<cstring>#include<cstdio>#include<algorithm>#define F(i,j,n) for(int i=j;i<=n;i++)#define D(i,j,n) for(int i=j;i>=n;i--)#define ll long long#define maxn 400005#define eps 1e-8using namespace std;int n,cnt,top;double a,b,r,x,y,angle,ans;const double pi=acos(-1);struct P{double x,y;P(double xx=0,double yy=0){x=xx;y=yy;}friend P operator -(P a,P b){return P(a.x-b.x,a.y-b.y);}friend double operator *(P a,P b){return a.x*b.y-a.y*b.x;}friend bool operator <(P a,P b){return fabs(a.y-b.y)<eps?a.x<b.x:a.y<b.y;}}p[maxn],s[maxn];inline P move(P a,double len,double angle){return P(a.x+len*cos(angle),a.y+len*sin(angle));}inline double dis(P a,P b){return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}inline bool cmp(P a,P b){double tmp=(a-p[1])*(b-p[1]);return fabs(tmp)<=eps?dis(p[1],a)<dis(p[1],b):tmp>0;}inline void solve(){F(i,2,cnt) if (p[i]<p[1]) swap(p[1],p[i]);sort(p+2,p+cnt+1,cmp);F(i,1,cnt){while (top>1&&(s[top]-s[top-1])*(p[i]-s[top-1])<eps) top--;s[++top]=p[i];}}int main(){scanf("%d",&n);scanf("%lf%lf%lf",&a,&b,&r);a-=2*r;b-=2*r;ans=2*pi*r;F(i,1,n){scanf("%lf%lf%lf",&x,&y,&angle);F(j,1,4){P tmp=move(P(x,y),b/2,angle+pi/2*(j-1));p[++cnt]=move(tmp,a/2,angle+pi/2*j);swap(a,b);}}solve();s[top+1]=s[1];F(i,1,top) ans+=sqrt(dis(s[i],s[i+1]));printf("%.2lf\n",ans);return 0;}
0 0
- BZOJ2829信用卡凸包
- bzoj2829 信用卡凸包
- 【bzoj2829】【信用卡凸包】【凸包】
- [BZOJ2829]信用卡凸包(凸包)
- bzoj2829: 信用卡凸包 计算几何 凸包
- BZOJ2829: 信用卡凸包(圆的凸包)
- [SHTSC 2012] 信用卡凸包
- 【BZOJ 2829】信用卡凸包 凸包
- [BZOJ]2829 信用卡凸包 凸包
- BZOJ 2829: 信用卡凸包 题解
- bzoj 2829: 信用卡凸包 (凸包)
- BZOJ-2829信用卡凸包 凸包+向量旋转计算
- 信用卡
- 信用卡
- 信用卡
- 信用卡
- 信用卡
- 信用卡基本知识
- Linux-python 安装,学习
- 123_inflate原理一
- Unable to to create media player
- 124_inflate原理二
- HDOJ/HDU 2710 Max Factor(素数快速筛选~)
- bzoj2829 信用卡凸包
- 125_ListView和UI卡顿
- 2 SparkStreaming运行机制和架构
- 126_发送自定义广播
- bzoj2823【AHOI2012】信号塔
- module.exports 与 exports的区别
- bzoj2146 Construct
- Install Oracle Java8 in Ubuntu via ppa
- javascript执行顺序总结