Codeforce--600d-area of Circles ' intersection

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.