//求在可以旋转的给定圆心和半径的半圆中最多点的个数
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<queue>
#define dist(a,b) sqrt(1.0*(a.x-b.x)*(a.x-b.x)+1.0*(a.y-b.y)*(a.y-b.y))
#define cross(a,b,c) 1.0*(b.x-a.x)*(c.y-a.y)-1.0*(b.y-a.y)*(c.x-a.x)
#define dot(a,b,c) (b.x-a.x)*(c.x-a.x)+(b.y-a.y)*(c.y-a.y)
#define delt(a) fabs(a)<eps?0:a>0?1:-1
#define pi acos(-1.0)
#define eps 1e-8
#define inf 1e20
#define N 1005
#define M 1005
using namespace std;
typedef __int64 i64;
struct TPoint
{
double x,y;
}pt[N],st;
double r;
int n,m,t;
void scan()
{
scanf("%d",&n);
m=0;
for(int i=0;i<n;i++)
{
scanf("%lf%lf",&pt[i].x,&pt[i].y);
if(dist(pt[i],st)<=r) pt[m++]=pt[i];
}
n=m;
}
bool cmp(TPoint a,TPoint b)
{
int d1=delt(cross(st,a,b));
return d1>0||(d1==0&&dist(st,a)<dist(st,b));
}
void solve()
{
int i,k,j;
sort(pt,pt+n,cmp);
if(n==0)
{
puts("0"); return;
}
for(i=t=0;i<n;i++)
{
for(j=m=0;j<n;j++)
{
if(delt(cross(st,pt[i],pt[j]))>=0) m++;
}
t=max(t,max(m,n-m));
}
printf("%d\n",t);
}
int main()
{
while(scanf("%lf%lf%lf",&st.x,&st.y,&r)!=EOF)
{
if(r<0) break;
scan();
solve();
}
return 0;
}
poj1106---计算几何
最新推荐文章于 2019-09-11 07:16:04 发布