For any point already covered some points of the circle, can be offset by the circle, so that it is guaranteed to cover the point on the basis of covering more points//to this offset to the limit, that is, just make two points in the circle//In fact, the idea of this problem and POJ1106 is similar, but see the scope of the party in the [ 0,10] Think of random algorithm go//There is also a n^2logn practice, learn the circle on the arc is covered by the number of marks #include<stdio.h> #include <algorithm> #include < Math.h>using namespace Std;const Double eps=1e-8;struct point {double X, y;}; struct node{double angle; int in;}; Node arc[1005]; Point p[305];d ouble Dist (Point p,point q) {return sqrt ((p.x-q.x) * (p.x-q.x) + (P.Y-Q.Y) * (P.Y-Q.Y));} int cmp (Node A,node b) {if (A.angle!=b.angle) return a.angle<b.angle; else return a.in>b.in;} int main () {#ifndef Online_judge freopen ("In.txt", "R", stdin); #endif//Online_judge int n; while (scanf ("%d", &n), n) {int ans=1; for (int i=0;i<n;i++) scanf ("%lf%lf", &p[i].x,&p[i].y); for (int i=0;i<n;i++) {int cnt=0; for (int j=0;j<n;j++) {if (i==j) continue; if (Dist (p[i],p[j]) >2.0+eps) continue; Double B=atan2 (p[j].y-p[i].y,p[j].x-p[i].x]; Double A=acos (Dist (p[i],p[j])/2); Arc[cnt].angle=b-a; Arc[cnt++].in=1; The point with the small angle as the point of entry arc[cnt].angle=b+a; Arc[cnt++].in=-1; } sort (arc,arc+cnt,cmp); int tmp=1; for (int j=0;j<cnt;j++) {//if (arc[j].in) tmp++; if is also set if the value is negative (as long as the non-0 is established) tmp+=arc[j].in; Ans=max (ANS,TMP); }} printf ("%d\n", ans); } return 0;}
POJ 1981 Circle and Points