Test instructions: Find the area of the intersecting circle. Learn from the great God code, the accuracy is very high.
1#include <fstream>2#include <iostream>3#include <string>4#include <complex>5#include <math.h>6#include <Set>7#include <vector>8#include <map>9#include <queue>Ten#include <stdio.h> One#include <stack> A#include <algorithm> -#include <list> -#include <ctime> the#include <memory.h> -#include <ctime> -#include <assert.h> - + #defineY1 AASDFASDFASDF - + #defineEPS 1e-16 A #defineM_PI 3.141592653589793 at Const intN =200005; - using namespacestd; - - Long Doublex1,y1,x2,y2,r1,r2; - - Long DoubleGdLong DoubleX1,Long DoubleY1,Long DoubleX2,Long Doubley2) in { - returnsqrt ((x1-x2) * (X1-X2) + (y1-y2) * (y1-y2)); to } + - Long DoubleSolve_cos (Long DoubleALong DoubleBLong Doublec) the { * returnACOs ((a*a+b*b-c*c)/(2*a*b)); $ }Panax Notoginseng - Long DoubleCutLong DoubleAngLong DoubleR) the { + Long Doubles1,s2; As1=ang*r*r/2; theS2=sin (ANG) *r*r/2; + returnS1-S2; - } $ $ Long DoubleSolve () - { - if(r1<R2) the { - swap (X1,X2);Wuyi swap (y1,y2); the swap (R1,R2); - } Wu Long DoubleCd=GD (x1,y1,x2,y2); - if(cd+r2<=r1+EPS) About returnr2*r2*M_pi; $ if(cd>=r1+r2-EPS) - return 0; - Long Doubleang1=Solve_cos (CD,R1,R2); - Long DoubleAng2=Solve_cos (CD,R2,R1); A returnCut (ang1*2, R1) +cut (ang2*2, r2); + } the - intMain () $ { theCin>>x1>>y1>>R1; theCin>>x2>>y2>>R2; theCout.precision ( A); thecout<<fixed<<solve () <<Endl; - return 0; in}
View Code
Codeforce--600d-area of Circles ' intersection