| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
一次AC,供后来的兄弟参考:#include<stdio.h>
typedef struct{
int x,y;
}P;
P point1[1001],point2[1001];
int cross(P a,P c,P b){
return (a.x-b.x)*(c.y-b.y)-(c.x-b.x)*(a.y-b.y);
};
int judge(P a,P b,float r){
if((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)<=r*r)
return 1;
return 0;
};
int main()
{
int i,j,k;
float r;
P a;
int n,temp,max;
while(scanf("%d%d%f",&a.x,&a.y,&r)!=EOF){
if(r<0)
return 0;
scanf("%d",&n);
i=1;
for(k=1;k<=n;k++){
scanf("%d%d",&point1[k].x,&point1[k].y);
if(judge(a,point1[k],r)){
point2[i].x=point1[k].x;
point2[i++].y=point1[k].y;
}
}
i--;
max=0;
for(j=1;j<=i;j++){
temp=0;
for(k=1;k<=i;k++)
if(cross(point2[j],a,point2[k])<=0){
temp++;
}
if(2*temp<i)
temp=i-temp;
if(temp>max)
max=temp;
}
printf("%d\n",max);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator