| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 4617 | Accepted: 2468 |
题目链接:http://poj.org/problem?id=1106
Description

Input
Output
Sample Input
25 25 3.5 7 25 28 23 27 27 27 24 23 26 23 24 29 26 29 350 200 2.0 5 350 202 350 199 350 198 348 200 352 200 995 995 10.0 4 1000 1000 999 998 990 992 1000 999 100 100 -2.5
Sample Output
3 4 4
Source
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const int M = 500;
const double pi = acos(-1.0);
double p[M];
const double eps=1e-8;
double pow1(double a,double b)
{
return (a - b) * (a - b);
}
double dist(double x1,double y1,double x2,double y2)
{
return pow1(y2,y1) + pow1(x2,x1);
}
double Atan2(double x1,double y1,double x2,double y2)
{
double x = x2 - x1;
double y = y2 - y1;
return atan2(y,x);//求出极角
}
int main()
{
// freopen("in","r",stdin);
double a,b,r,x,y;
while(~scanf("%lf %lf %lf",&a,&b,&r) && r > eps)
{
int m,to,Max;
scanf("%d",&m);
to = Max = 0;
while(m--)
{
scanf("%lf %lf",&x,&y);
if(dist(x,y,a,b) > r * r) continue;
p[to++] = Atan2(a,b,x,y);
if(p[to - 1] < eps) p[to - 1] += 2 * pi;
}
sort(p,p + to);
for(int i = to; i < to * 2; i++)
{
p[i] = p[i - to]+2*pi; //方便下面的处理;
}
for(int i = 0; i < to; i++)
{
int t = 1;
for(int j = i + 1; j < to * 2; j++)
{
double ang=p[j]-p[i];
if(ang>pi) break;
t++;
}
Max = max(Max, t);
}
printf("%d\n",Max);
}
return 0;
}原文地址:http://blog.csdn.net/zsgg_acm/article/details/40210551