Main topic
Give some points on the plane to find out how many points a unit circle can cover.
Ideas
Data range 300, but no use, multiple sets of data is to card o ( < Span style= "Position:absolute; Clip:rect (1.976em 1000.003em 2.723em-0.477em); Top: -2.557em; Left:0.003em; " >n 3 ) , but the constant optimization of the better words in the POJ can be, but BZ still can't live. We need to find a O( n 2 Log N) The practice.
The practice is to enumerate each point and make a single circle that points to the center of the circle. After that all the points in the circle are made, the points are the center of the unit circle, and the beginning of the unit circle will produce an arc, and finally ask which arc is overwritten by the most times is the answer.
CODE
o ( < Span style= "Position:absolute; Clip:rect (1.976em 1000.003em 2.723em-0.477em); Top: -2.557em; Left:0.003em; " >n 3 ) Water over version
#define _crt_secure_no_warnings#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define MAX 510#define EPS 1e-7using namespace STD;structpoint{Doublex, y; Point (Const Double&_,Const Double&__): X (_), Y (__) {} point () {}operator+(ConstPoint &a)Const{returnPoint (x + a.x, y + a.y); } pointoperator-(ConstPoint &a)Const{returnPoint (x-a.x, Y-A.Y); } pointoperator*(Const Double&a)Const{returnPoint (X * A, Y * a); } pointoperator/(Const Double&a)Const{returnPoint (x/a, y/a); }voidRead () {scanf("%LF%LF", &x, &y); }}point[max];inline DoubleCalc (ConstPoint &p1,ConstPoint &p2) {return sqrt((p1.x-p2.x) * (p1.x-p2.x) + (P1.Y-P2.Y) * (P1.Y-P2.Y));inlinePoint Change (ConstPoint &v) {returnPoint (-v.y, v.x);}intPointsBOOLV[max];int Stack[MAX], top;inline intGetans (ConstPoint &p1,ConstPoint &p2) {Doubledis = Calc (p1, p2)/2;if(Dis >1.0)return 0; Point o = Point ((p1.x + p2.x)/2, (P1.y + p2.y)/2) + (change (P1-P2)/(DIS *2)) *sqrt(1-Dis * dis);intRe =0; for(inti =1; I <= top; ++i) Re + = Calc (point[Stack[i]], O) <=1.0+ EPS;returnRe +1;}intMain () { while(scanf("%d", &points), points) { for(inti =1; I <= points; ++i) Point[i]. Read ();intAns =1; for(inti =1; I <= points; ++i) {top =0; for(intj =1; J <= points; ++J)if(I! = J && Calc (Point[i], point[j]) <2.0)Stack[++top] = j; for(intj =1; J <= Top; ++j) ans = max (ans, Getans (point[i), point[Stack[j]]); }printf("%d\n", ans); }return 0;}
POJ 1981 Circle and Points compute geometry