Circular intersecting, tangent, absent, containing

Source: Internet
Author: User

From BNU warm-up a geometric problem, personal feeling is OK, after all, q God card 7 times before the past.

E. School flowertime limit:1000msmemory limit:65536kb64-bit integer IO format:%lld Java class name: Main Submit Status

The school's lawn was recently filled with beautiful flowers, and in order to water the flowers, the school purchased two sprinklers for irrigation. Each nozzle has a spray radius that can be watered to the plants within the blast radius. Some of the flowers on the lawn can only be irrigated by a sprinkler, and some will be irrigated at the same time by two sprinklers, which grow more exuberant.

Now, ch0588 want to ask you to help calculate how much area can be irrigated by two nozzles at the same time? (Medium red area for the request)

(The red part is the area to be asked)

Input

Input data has only two lines of real numbers, separated by spaces

X1 y1 R1

X2 y2 R2

Represents the position (Xi,yi) of the two I nozzles respectively, and its jet radius ri.

(0<xi,yi,ri<1000.0)

Output

Output one line, the area in the title description (retain two decimal places)

Sample Input
1.0 3.0 3.01.0 8.0 4.0
Sample Output
6.64
Hint

value of π:3.1415926

Problem Solving Ideas:

There is no difficulty in thinking, mainly to discuss the relationship between the various positions of the two circles, and then get the results we need ...

The absent and the inclusion can be written directly, but the intersection of the words, to hand push the formula.

Code:

1# include<cstdio>2# include<iostream>3# include<Set>4# include<cmath>5# include<iomanip>6 7 using namespacestd;8 9# define PI3.1415926Ten  One intMainvoid) A { -     Doublex1,y1,r1; -     Doublex2,y2,r2; theCin>>x1>>y1>>R1; -Cin>>x2>>y2>>R2; -  -     Doubles; +     DoubleR_ans = Fabs (r2-R1); -  +     DoubleD = sqrt ((x2-x1) * (x2-x1) + (y2-y1) * (y2-y1)); A     if(d >= r1+R2) at{// to -s =0.00; -     } -     Else if(d <=R_ans) -{//included -         if(R2 >=R1) in         { -s = pi*r1*R1; to         } +         Else -         { thes = pi*r2*R2; *         } $     }Panax Notoginseng     Else -{//intersect the         DoubleA,aa; +         DoubleB,BB; AA = (r1*r1+ (x2-x1) * (x2-x1) + (y2-y1) * (y2-y1)-R2*R2)/(2*r1*d); theAA =2*ACOs (a); +b = (r2*r2+ (x2-x1) * (x2-x1) + (y2-y1) * (y2-y1)-R1*R1)/(2*r2*d); -BB =2*ACOs (b); $         DoubleS1 = R1*r1*sin (aa)/2; $         Doubles2 = R2*r2*sin (BB)/2; -         DoubleS3 = r1*r1*aa/2; -         DoubleS4 = r2*r2*bb/2; thes = s3-s1+s4-S2; - Wuyi     } theprintf"%.2f\n", s); -  Wu  -  About  $  -     return 0; -}

Circular intersecting, tangent, absent, containing

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.