#include #include #include #include using namespace std; double PI = 3.1415926; double interception(int x1, int x2, int y1, int y2, int R1, int R2) { double result = 0; double d = sqrt((x2 - x1)*(x2-x1)+(y2-y1)*(y2-y1)) / 2; double angle2 = 2*acos(d/R2)*180/PI; result += R2*R2/2*(angle2*PI/180 - sin(angle2*PI/180)); double angle1 = 2*acos(d/R1)*180/PI; result += R1*R1/2*(angle1*PI/180 - sin(angle1*PI/180)); return result; } int main() { ifstream fin; fin.open("circles.in"); int x1, x2, y1, y2, r1, r2, R1, R2; fin >> x1 >> y1 >> r1 >> R1 >> x2 >> y2 >> r2 >> R2; double area1 = PI * R1 * R1 - PI * r1 * r1; double area2 = PI * R2 * R2 - PI * r2 * r2; double result = area1 + area2; if(sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)) < R1 + R2) { result -= interception(x1, x2, y1, y2, R1, R2); double d = sqrt((x2 - x1)*(x2-x1)+(y2-y1)*(y2-y1)); if(d - R2 < r1) { result += 2*interception(x1, x2, y1, y2, r1, R2); } if(d - R1 < r2) { result += 2*interception(x1, x2, y1, y2, R1, r2); } } ofstream fout; fout.open("circles.out"); fout << fixed << setprecision(6) << result << endl; return 0; }