Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <cmath>
- #define EPSILON 1e-8
- using namespace std;
- int N,best,tmp;
- double a,b,X[205],Y[205],dx,dy,L,D,cx,cy,tx,ty;
- bool eq(double a,double b){
- return (a-b < EPSILON && b-a < EPSILON);
- }
- double sq(double x){return x*x;}
- int main(){
- while(scanf("%lf%lf",&a,&b) == 2)
- X[N] = a,Y[N++] = b;
- for(int i=0;i<N;++i)
- for(int j=i+1;j<N;++j)
- 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)){
- dx = Y[i] - Y[j], dy = (X[i] - X[j]) * -1.0;
- cx = (X[i] + X[j]) / 2.0, cy = (Y[i] + Y[j]) / 2.0;
- D = dx*dx + dy*dy;
- L = 6.25 - sq(X[i]-cx) - sq(Y[i]-cy);
- if(!eq(D,0.0)){
- dx *= sqrt(L/D);
- dy *= sqrt(L/D);
- }
- else dx = dy = 0.0;
- tx = cx + dx, ty = cy + dy;
- tmp = 0;
- for(int k=0;k<N;++k)
- if( sq(tx-X[k]) + sq(ty-Y[k]) < 6.25 || eq(sq(tx-X[k]) + sq(ty-Y[k]),6.25) ) ++tmp;
- best = max(tmp,best);
- tmp = 0;
- tx = cx - dx,ty = cy - dy;
- for(int k=0;k<N;++k)
- if( sq(tx-X[k]) + sq(ty-Y[k]) < 6.25 || eq(sq(tx-X[k]) + sq(ty-Y[k]),6.25) ) ++tmp;
- best = max(tmp,best);
- }
- printf("%d\n",best);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement