When the distance of two points is less than the diameter, a unit circle is determined by them for the chord (although there are two circles, but want to know that only one can) to calculate the coverage of how many points.
#include <cstdio> #include <cmath> #define N 301#define eps 1e-5using namespace std;int n,ans,tol;double X[n], Y[n],dx,dy;inline double Sqr (double x) {return x*x;} inline double dis (int a,int b) {return sqrt ((X[a]-x[b]) * (X[a]-x[b]) + (Y[a]-y[b]) * (Y[a]-y[b]));} inline void Solve () {tol=0; for (int i=1; i<=n; i++) if (DIS (0,i) <=1+eps) tol++; if (Tol>ans) ans=tol;} inline void get (int a,int b) {double V=atan ((X[b]-x[a])/(y[a]-y[b]);//equals 0 o'clock returns INF,V=PI/2 double c=sqrt (DIS (A, b )/2.0)); dx= C*cos (v); dy= C*sin (v);} int main () {while (scanf ("%d", &n) &&n) {Ans=1; for (int i=1; i<=n; i++) scanf ("%lf%lf", &x[i],&y[i]); for (int i=1, i<=n; i++) for (int j=i+1; j<=n; J + +) if (DIS (i,j) <2) {Double m X= (X[i]+x[j])/2.0,my= (Y[i]+y[j])/2.0; Get (I,J); X[0]=mx+dx,y[0]=my+dy; Solve (); }printf ("%d\n", ans); }}
"POJ 1981" Circle and Points