//题意: 给出一个半圆形的坐标和半径,另给出一些平面内的点,求此半圆最多覆盖的点的数目.
#include<stdio.h>
#define N 1000
struct POINT
{
double x,y;
}centre,point[N];
int count;
double distance(double x1,double y1,double x2,double y2)
{
return ((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
double chaji(POINT a,POINT b,POINT c)
{
return ((b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y));
}
int work()
{
int max=0,i,ans,j;
for(i=0;i<count;i++)
{
ans=1;
for(j=0;j<count;j++)
{
if(i==j)
continue;
if(chaji(centre,point[i],point[j])>=0) //注意端点
ans++;
}
if(ans>max)
max=ans;
}
return max;
}
int main()
{
int n,i;
double r,a,b;
while(scanf("%lf%lf%lf",¢re.x,¢re.y,&r)!=EOF)
{
if(r<0) break;
scanf("%d",&n);
count=0;
for(i=0;i<n;i++)
{
scanf("%lf%lf",&a,&b);
if(distance(a,b,centre.x,centre.y)<=r*r)
{
point[count].x=a;
point[count++].y=b;
}
}
printf("%d\n",work());
}
return 0;
}
poj 1106
最新推荐文章于 2019-07-29 22:57:01 发布