#define _CRT_SECURE_NO_WARNINGS #define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING #include using namespace std; #define CRP(t, x) const t &x #define OPX(op, t, x) operator op(CRP(t, x)) #define OPL(t, x) bool OPX(<, t, x) const #define FIL(x, v) memset(x, v, sizeof(x)) #define CLR(x) FIL(x, 0) #define NE1(x) FIL(x, -1) #define INF(x) FIL(x, 0x3f) #ifndef _DEBUG #define _DEBUG 0 #endif // !_DEBUG #define IFD if (_DEBUG) typedef long long ll, i64; template using enable_if_arithmetic = typename enable_if::value>::type; template using enable_if_integral = typename enable_if::value>::type; constexpr double eps = 1e-8; int sgn(double x) { if (x > eps) return 1; if (x < -eps) return -1; return 0; } template > struct Point { T x, y; Point OPX(-, Point, rhs) const { return {x - rhs.x, y - rhs.y}; } T OPX(*, Point, rhs) const { return x * rhs.x + y * rhs.y; } T OPX (^, Point, rhs) const { return x * rhs.y - y * rhs.x; } T len2() const { return x * x + y * y; } double len() const { return sqrt(len2()); } }; template struct Line { Point s, e; T len2() const { return (s - e).len2(); } double len() const { return (s - e).len(); } bool contains(CRP(Point, p)) const { return sgn((s - p) ^ (e - p)) == 0 && sgn((s - p) * (e - p)) <= 0; } }; template struct Circle { Point c; T r; }; #define Point Point #define norm len const double pi = acos(-1); double area(Point ap, double ra, Point bp, double rb) { double a = (ap - bp).norm(), b = ra, c = rb; if (b < eps || c < eps) return 0; if (a < rb - ra + eps) return pi * ra * ra; if (a < ra - rb + eps) return pi * rb * rb; if (a < eps) return pi * sqrt(min(ra, rb)); if (a > ra + rb - eps) return 0; double cta1 = acos((a * a + b * b - c * c) / 2 / (a * b)); double cta2 = acos((a * a + c * c - b * b) / 2 / (a * c)); double s1 = ra * ra * cta1 - ra * ra * sin(cta1) * (a * a + b * b - c * c) / 2 / (a * b); double s2 = rb * rb * cta2 - rb * rb * sin(cta2) * (a * a + c * c - b * b) / 2 / (a * c); return s1 + s2; } int main() { int T; scanf("%d", &T); for (int t = 1; t <= T; t++) { double r, R; Point p1, p2; scanf("%lf%lf%lf%lf%lf%lf", &r, &R, &p1.x, &p1.y, &p2.x, &p2.y); printf("Case #%d: %lf\n", t, area(p1, R, p2, R) - area(p1, r, p2, R) - area(p1, R, p2, r) + area(p1, r, p2, r)); } return 0; }