Advertisement
Guest User

Untitled

a guest
Jan 19th, 2012
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. #define EPSILON 1e-8
  5. using namespace std;
  6.  
  7. int N,best,tmp;
  8. double a,b,X[205],Y[205],dx,dy,L,D,cx,cy,tx,ty;
  9.  
  10. bool eq(double a,double b){
  11.     return (a-b < EPSILON && b-a < EPSILON);
  12. }
  13.  
  14. double sq(double x){return x*x;}
  15.  
  16. int main(){
  17.     while(scanf("%lf%lf",&a,&b) == 2)
  18.         X[N] = a,Y[N++] = b;
  19.     for(int i=0;i<N;++i)
  20.         for(int j=i+1;j<N;++j)
  21.             if( sq(X[i]-X[j]) + sq(Y[i]-Y[j]) < 25.0 || eq(sq(X[i]-X[j]) + sq(Y[i]-Y[j]),25.0)){
  22.                 dx = Y[i] - Y[j], dy = (X[i] - X[j]) * -1.0;
  23.                 cx = (X[i] + X[j]) / 2.0, cy = (Y[i] + Y[j]) / 2.0;
  24.                 D = dx*dx + dy*dy;
  25.                 L = 6.25 - sq(X[i]-cx) - sq(Y[i]-cy);
  26.                 if(!eq(D,0.0)){
  27.                     dx *= sqrt(L/D);
  28.                     dy *= sqrt(L/D);
  29.                 }
  30.                 else dx = dy = 0.0;
  31.                 tx = cx + dx, ty = cy + dy;
  32.                 tmp = 0;
  33.                 for(int k=0;k<N;++k)
  34.                     if( sq(tx-X[k]) + sq(ty-Y[k]) < 6.25 || eq(sq(tx-X[k]) + sq(ty-Y[k]),6.25) ) ++tmp;
  35.                 best = max(tmp,best);
  36.                 tmp = 0;
  37.                 tx = cx - dx,ty = cy - dy;
  38.                 for(int k=0;k<N;++k)
  39.                     if( sq(tx-X[k]) + sq(ty-Y[k]) < 6.25 || eq(sq(tx-X[k]) + sq(ty-Y[k]),6.25) ) ++tmp;
  40.                 best = max(tmp,best);
  41.             }
  42.     printf("%d\n",best);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement