Surface
Test instructions: give you n a circle, each circle has a weight, you can choose a point, you can get a circle covering this point, the weight of the largest m weights, ask the most weight is how much
Problem: It seems to be a question of Syria .... We figure out that we are looking for the round and round the part inside the point, we take a closer look,
the intersection of 2 circles must be in the AH!
don't worry, two circle contains, all is the intersection, take where? Of course, Small Circle Center is enough AH (round is not much, write the time directly to all the center is thrown in)
Then the enumeration determines that each point has not been in the M circle on the line, here to maintain the largest m, with a heap is good
1#include <bits/stdc++.h>2 using namespacestd;3typedefLong Doubleld;4 ConstLD EPS = 1e-Ten;5 intdcmp (ld x)6 {7 if(Fabs (x) < EPS)return 0;8 returnX <0? -1:1;9 }TenLD SQR (ld x) {returnX *x;} One struct Point A { - ld x, y; -Point (ld x =0, ld y =0): X (x), Y (y) {} the }; -Pointoperator- (Constpoint& A,Constpoint&B) - { - returnPoint (a.x-b.x, A.Y-b.y); + } - BOOL operator== (Constpoint& A,Constpoint&B) + { A returnDCMP (a.x-b.x) = =0&& dcmp (a.y-b.x) = =0; at } -LD Dot (Constpoint& A,Constpoint&B) - { - returna.x * b.x + a.y *b.y; - } - ld dis (point a,point B) in { - returnsqrt (SQR (a.x-b.x) +SQR (a.y-b.y)); to } +LD Length (Constpoint& A) {returnsqrt (Dot (A, a));} -LD angle (point v) {returnatan2 (V.Y, v.x);} the structCircle * { $ Point C;Panax Notoginseng ld r,v; - Circle () {} the Circle (point C, LD R): C (c), R (r) {} +Inline Point Point (Doublea) A { the returnPoint (C.x+cos (a) *r, C.y+sin (a) *R); + } -}a[ the]; $ intGetcirclecircleintersection (Circle C1, Circle C2,point &t1,point &T2) $ { -LD d = Length (c1.c-c2.c); - if(DCMP (d) = =0) the { - if(dcmp (C1.R-C2.R) = =0)return-1; Wuyi return 0; the } - if(dcmp (C1.R + c2.r-d) <0)return 0; Wu if(DCMP (Fabs (C1.R-C2.R)-D) >0)return 0; -LD a = angle (c2.c-c1.c); Aboutld da = ACOs ((C1.R*C1.R + D*D-C2.R*C2.R)/(2*c1.r*d)); $Point P1 = C1.point (a-da), p2 = c1.point (A +da); -t1=P1; - if(P1 = = p2)return 1; -T2=P2; A return 2; + } thePoint jd[20000]; - ld Ans,sum; $ intN,m,t,tot; thepriority_queue<int,vector<int>,greater<int> >Q; the intMain () the { thescanf"%d",&T); - while(t--) in { thetot=0; theans=0; Aboutscanf"%d%d",&n,&m); the for(intI=1; i<=n;i++) scanf ("%LF%LF%LF%LF",&a[i].c.x,&a[i].c.y,&a[i].r,&a[i].v); the for(intI=1; i<=n;i++) the for(intj=i+1; j<=n;j++) + { - Point t1,t2; the intwhy=getcirclecircleintersection (A[I],A[J],T1,T2);Bayi if(why==1) the { thetot++; -jd[tot]=T1; -}Else the if(why==2) the { thetot++;jd[tot]=T1; thetot++;jd[tot]=T2; - } the } the for(intI=1; i<=n;i++) the {94tot++; thejd[tot]=a[i].c; the } the for(intI=1; i<=tot;i++)98 { About for(intj=1; j<=n;j++) - if(DCMP (DIS (jd[i],a[j].c)-A[J].R) <=0) 101 {102 Q.push (A[J].V);103 if((int) Q.size () >m) Q.pop ();104 } thesum=0;106 while(!q.empty ()) sum+=q.top (), Q.pop ();107ans=Max (ans,sum); 108 } 109printf"%. lf\n", ans); the } 111}
gym-101915b Ali and Wi-Fi compute geometry to find two circular intersections