本文主要是介绍HDU-5120-10.1训练赛-,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
模板题
CODE
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define esp 1e-8using namespace std;struct Circle{double x,y;double r;
};double calArea(Circle c1, Circle c2)
{double d;double s,s1,s2,s3,angle1,angle2,temp;d=sqrt((c1.x-c2.x)*(c1.x-c2.x)+(c1.y-c2.y)*(c1.y-c2.y));if(d>=(c1.r+c2.r))//两圆相离return 0;if((c1.r-c2.r)>=d)//两圆内含,c1大return acos(-1.0)*c2.r*c2.r;if((c2.r-c1.r)>=d)//两圆内含,c2大return acos(-1.0)*c1.r*c1.r;angle1=acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));angle2=acos((c2.r*c2.r+d*d-c1.r*c1.r)/(2*c2.r*d));s1=angle1*c1.r*c1.r;s2=angle2*c2.r*c2.r;s3=c1.r*d*sin(angle1);s=s1+s2-s3;return s;
}
int main()
{Circle a,b,c,d;double s,s1,s2,s3,x1,r,R,x2,y1,y2;int T,k=1;scanf("%d",&T);while(T--){scanf("%lf%lf%lf%lf%lf%lf",&r,&R,&x1,&y1,&x2,&y2);a.r=r;a.x=x1;a.y=y1;b.r=r;b.x=x2;b.y=y2;c.r=R;c.x=x1;c.y=y1;d.r=R;d.x=x2;d.y=y2;s=calArea(c,d);s1=calArea(a,b);s2=calArea(a,d);s3=calArea(b,c);s=s-s2-s3+s1;printf("Case #%d: %0.6f\n",k++,s);}return 0;
}
这篇关于HDU-5120-10.1训练赛-的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!