poj 1106

//题意: 给出一个半圆形的坐标和半径,另给出一些平面内的点,求此半圆最多覆盖的点的数目.

#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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值