Find the feasible minimum radius for the second radius of each circle, and then take the smallest radius.
For the intersection of the two circles, we only need to find two slices, and then subtract two full equi triangles.
# Include <cstdio> # include <iostream> # include <cmath> # include <algorithm> using namespace STD; # define PI ACOs (-1.0) # define EPS 1e-8 # define maxn 50int N; struct point {Double X; Double Y; Double R;} C [maxn]; double DIS (point a, point B) {return SQRT (. x-b.x) * (. x-b.x) +. y-b.y) * (. y-b.y);} double area (point a, double Ra, point B, double Rb) {double ans = 0; double D = DIS (a, B); double temp; if (RA <Rb) Swap (RA, Rb); I F (D> = Ra + RB) return 0; If (d <= Ra-Rb) return pI * RB; double angle1 = ACOs (Ra * RA + D * D-Rb * Rb)/2.0/RA/D ); double angle2 = ACOs (rb * RB + D * D-Ra * RA)/2.0/Rb/d); ANS-= D * ra * sin (angle1 ); ans + = angle1 * ra * RA + angle2 * RB; return ans;} bool cover_half (point a, double Ra, point B, double RB) // A indicates the circle with an umbrella and B indicates other circles {return area (A, Ra, B, Rb)> = 0.5 * RB * PI ;} bool isok (Double R, int K) {for (INT I = 1; I <= N; I ++) {If (! Cover_half (C [K], R, C [I], C [I]. r) return false;} return true;} int main () {int CAS; scanf ("% d", & CAS); While (CAS --) {scanf ("% d", & N); For (INT I = 1; I <= N; I ++) {scanf ("% lf ", & C [I]. x, & C [I]. y, & C [I]. r);} double ans = 5000000; For (INT I = 1; I <= N; I ++) {double L = 0.0, r = 5000000, mid; while (L + EPS <= r) {mid = (L + r)/2; If (isok (MID, I) r = mid-EPS; else l = Mid + EPS;} ans = min (ANS, mid);} printf ("%. 4lf \ n ", ANS);} return 0 ;}