向量的叉乘大于0即是在直线的同一边。
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;
struct point{
double x;
double y;
}p[1000],center;
int tmax(int a, int b){
return a>b?a:b;
}
double dis(point a,point b){ //d^2
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
double multi(point a,point b,point o){ //叉乘 a*d-b*c
return(a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x);
}
int main(){
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
int n;
double r;
while(cin>>center.x>>center.y>>r && r>=0){
int result = 0;
cin>>n;
for(int i=0;i<n;i++){
cin>>p[i].x>>p[i].y;
}
for(int k=0;k<n;k++){
int count1 = 0;
int count2 = 0;
if(dis(p[k],center)<=r*r){
for(int j=0;j<n;j++){
if(dis(p[j],center)<=r*r){
if(multi(p[k],p[j],center)>0)
count1++;
else
count2++;
}
}
}
result = tmax(result,tmax(count1,count2));
}
cout<<result<<endl;
}
return 0;
}