#include #include using namespace std; #define NrE 3 #define sqr(x) ((x) * (x)) #define INF 1e9 struct Elipsa { double cx, cy, rx, ry; double a, b, c_part, x0; void read() { scanf("%lf %lf %lf %lf\n", &cx, &cy, &rx, &ry); a = 1.0 / sqr(rx); b = -2.0 * cx / sqr(rx); c_part = sqr(cx) / sqr(rx) - 1.0; x0 = -b / (2.0 * a); } pair intersect(const double y) const { if (y < cy - ry || y > cy + ry) { return make_pair(0.0, 0.0); } const double c = c_part + sqr(y - cy) / sqr(ry); const double delta = sqr(b) - 4.0 * a * c; if (delta < 0) { fprintf(stderr, "Error: %lf %lf\n", y, delta); //return make_pair(0.0, 0.0); } const double dif = sqrt(delta) / (2.0 * a); return make_pair(cx - dif, cx + dif); } }; Elipsa elipse[NrE]; int main() { #ifdef WIN32 freopen("elipse.in", "rb", stdin); freopen("elipse.out", "wb", stdout); #endif for (int i = 0; i < NrE; i++) { elipse[i].read(); } double ans = 0.0; const double PAS = 0.00004; for (double y = -76; y <= 76; y += PAS) { pair points[2 * NrE]; for (int i = 0; i < NrE; i++) { pair interval = elipse[i].intersect(y + PAS * 0.5); points[2 * i] = make_pair(interval.first, false); points[2 * i + 1] = make_pair(interval.second, true); } sort(points, points + 2 * NrE); double lastPoz = INF; double lung = 0.0; int nrOpen = 0; for (int i = 0; i < 2 * NrE; i++) { if (points[i].second) { nrOpen--; if (nrOpen < 0) { fprintf(stderr, "Wrong!\n"); } if (nrOpen == 0) { lung += points[i].first - lastPoz; } } else { if (nrOpen == 0) { lastPoz = points[i].first; } nrOpen++; } } const double inc = lung * PAS; ans += inc; } printf("%.8lf", ans); return 0; }