题意:给定两圆坐标,及面积和, 并且若干个点的坐标,问最少有多少点不再园内。
思路:枚举一个圆的半径求另一个,并且两个圆都要枚举求最值。(因为PI值定义为int错了若干次- -)
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define LL __int64
using namespace std;
int n;
const double PI=3.141;
const int inf=0x3f3f3f3f;
double a[1100],b[1100];
double dis(double x,double y,int i){
return ((x-a[i])* (x-a[i])+ (y-b[i])* (y-b[i]) );
}
int so(double x,double y,double xx,double yy,double s){
double r,sum;int i,j,ans=0;
for(i=0;i<n;++i){
r=dis(x,y,i);
sum=r*PI;
if(sum<=s){
sum=s-sum;
int t=0;
double rt=max(sum/PI,0.0/PI);
for(j=0;j<n;++j){
if(dis(x,y,j)<=r||dis(xx,yy,j)<=rt ){
t++;
}
}
ans=max(ans,t);
}
}
return ans;
}
int main(){
int i,j,k;
double x1,x2,y1,y2,s;
int cl=0;
while(~scanf("%d",&n)&&n){
scanf("%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&s);
for(i=0;i<n;++i){
scanf("%lf%lf",&a[i],&b[i]);
}
k=max( so(x1,y1,x2,y2,s),so(x2,y2,x1,y1,s) );
int t=0;
for(j=0;j<n;++j){
if(dis(x1,y1,j)<=(s/PI) )
t++;
}
k=max(k,t);
t=0;
for(j=0;j<n;++j){
if(dis(x2,y2,j)<=(s/PI) )
t++;
}
k=max(k,t);
printf("%d. %d\n",++cl,n-k);
}
return 0;
}