HDU 5120 (formula for finding the area of intersection of two circles)

Source: Internet
Author: User
Tags acos cas cos

S = a large b large-a large B small-a small B large + a small B small. (A is a ring, large represents a great circle, B is the same). Then directly set the template ,,,,

1#include <stdio.h>2#include <algorithm>3#include <string.h>4#include <cmath>5 using namespacestd;6 7 Const DoubleEPS = 1e-8;8 Const DoublePI = ACOs (-1.0);9 Ten intSgnDoublex) One { A     if(Fabs (x) < EPS)return 0; -     if(X <0)return-1; -     Else return 1; the } - struct Point - { -     Doublex, y; + Point () {} -Point (Double_x,Double_y) +     { Ax = _x; y =_y; at     } -Pointoperator-(ConstPoint &b)Const -     { -         returnPoint (X-b x, Y-b. y); -     } -  in     Double operator^ (ConstPoint &b)Const -     { to         returnX*b. y-y*b. x; +     } -  the     Double operator* (ConstPoint &b)Const *     { $         returnX*b. x + y*b. y;Panax Notoginseng     } -  the     voidTransxy (DoubleB) +     { A         Doubletx = X,ty =y; thex = tx* cos (B)-ty*sin (B); +y = tx* sin (B) + ty*cos (B); -     } $ }; $  - DoubleDist (Point A, point B) - { the     returnsqrt (A-B) * (Ab)); - }Wuyi  the DoubleAc (Point C1,DoubleR1, point C2,DoubleR2) - { Wu     DoubleD =Dist (C1,C2); -     if(R1 + R2 < D + EPS)return 0; About     if(D < Fabs (R1-R2) +EPS) $     { -         DoubleR =min (r1,r2); -         returnpi*r*R; -     } A     Doublex = (d*d + r1*r1-r2*r2)/(2*d); +     DoubleT1 = ACOs (x/R1); the     DoubleT2 = ACOs ((d-x)/r2); -     returnR1*R1*T1 + r2*r2*t2-d*r1*sin (t1); $ } the  the intMain () { the     intT; Point C1, C2; the     Doubleans, R, R, X1, y1, x2, y2; -scanf"%d", &T); in      for(intCAS =1; CAS <= T; ++CAs) { thescanf"%LF%LF%LF%LF%LF%LF", &r, &r, &x1, &y1, &AMP;X2, &y2); thec1.x = x1; C1.Y =Y1; Aboutc2.x = x2; C2.Y =Y2; theAns = AC (c1, R, C2, R)-AC (C1, R, C2, R)-Ac (C1, R, C2, R) the+Ac (C1, R, C2, r); theprintf"Case #%d:%.6lf\n", CAs, ans); +     } -     return 0; the}

HDU 5120 (formula for finding the area of intersection of two circles)

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.