#include #include #include #include #include // [20 Sep 2005, by yuizumi] // It is recommended to set EPS to about 10^(-8) (1e-8) when generating // the judge's output; the copmiler option -D may be useful. #ifndef EPS #define EPS (1e-6) // much enough to reduce an error to 10^(-3) #endif using namespace std; class ellipse_t { private: double a, b; public: ellipse_t(void) { } ellipse_t(double a, double b) : a(a), b(b) { } public: double operator() (double x) const { return b * sqrt(a * a - x * x) / a; } }; static ellipse_t f, g; double integrate(double xmin, double xmax) { double Smax = min(f(xmin), g(xmin)) * (xmax - xmin); double Smin = min(f(xmax), g(xmax)) * (xmax - xmin); if(fabs(Smax - Smin) >= EPS) { double x = (xmin + xmax) / 2.0; return integrate(xmin, x) + integrate(x, xmax); } else { return (Smax + Smin) / 2.0; } } int main(void) { int n; cin >> n; while(n-- > 0) { double a1, b1, a2, b2; cin >> a1 >> b1 >> a2 >> b2; assert(a1 > b1); assert(a2 < b2); f = ellipse_t(a1, b1); g = ellipse_t(a2, b2); // output six decimal digits for judge's output cout << fixed << setprecision(6); cout << integrate(0.0, min(a1,a2)) * 4.0 << endl; } }