http://acm.hdu.edu.cn/showproblem.php?pid=1798
Give you two circles to find the area of the shaded part
Find out the area of the two sector minus the four-sided shape
The area of the sector is the square of the radius of the degree (radian)
Can not use pi 3.1415926 to use ACOs (-1.0);
Find the quadrilateral area is two triangles with Helen Formula
Because of the high accuracy, we can't use pi 3.1415926.
#include <iostream>#include<cstring>#include<algorithm>#include<queue>#include<cstdio>#include<cstdlib>#include<cctype>#include<math.h>using namespacestd;#defineMemset (A, B) memset (A,b,sizeof (a))#defineN 1100000typedefLong Longll;#definePI 3.1415926intMain () {DoubleX1,Y1,R1,X2,Y2,R2; while(SCANF ("%lf%lf%lf%lf%lf%lf", &X1,&Y1,&R1,&X2,&Y2,&R2)! =EOF) { DoubleRr=min (R1,R2); DoubleL=sqrt ((x1-x2) * (X1-X2) + (y1-y2) * (y1-y2)); if(l>=r1+R2) {printf ("0.000\n"); Continue; } Else if(L<=fabs (r1-R2)) {printf ("%.3lf\n", ACOs (-1.0) *rr*RR); Continue; } Doublecos1= (R1*R1+L*L-R2*R2)/(2.0*r1*l); DoubleCos2= (R2*R2+L*L-R1*R1)/(2.0*r2*l); DoubleSs1=r1*acos (COS1) *r1;///area of the R1 sector DoubleSs2=r2*acos (COS2) *R2; Doublep= (r1+r2+l)/2.0;/// Doubles=2*sqrt (p* (P-R1) * (P-R2) * (p-l));///the area of the four-sided shapeprintf"%.3lf\n", ss1+ss2-R); } return 0;}
Tell me the area---hdu1798 (mathematical geometry)