Circle and Ring
Time Limit: 1 Second
Memory Limit: 32768 KB
Given a circle and a ring, your task is to calculate the area of their intersection.
Input
This problem contains multiple test cases, process to the end of file.
For each case, there are two lines. The first line contains three real numbers x', y' and r' (0 <= r' <= 1024) representing the circle. The second line contains four real numbers x, y, r and R (0 <= r <= R <= 1024) representing the ring.
Output
For each case, output the area with the accuracy of three digits after decimal point in a signal line.
Never output "-0.000"!
Sample Input
10 0 20
-10 0 10 20
20 30 15
40 30 0 30
Sample Output
351.041
608.366
Author:
WU, Zejun
Source:
ZOJ Monthly, November 2008
题意:给出一个圆的圆心坐标和半径,以及一个圆环的坐标和内外圆的半径,求这个圆和圆环的相交面积。
经分析可得,一共有如下几种情况:

通过计算可得出:
圆和圆环的相交面积 = 圆和圆环中大圆的相交面积 - 圆和圆环中小圆的相交面积。
#include
#include
#include
#include
#include
#include
#include