[极大化 极角排序] POJ 1981 Circle and Points & BZOJ 1338 Pku1981 Circle and Points单位圆覆盖

必然卡在一个点上 然后剩余每个点对应极角区间


#include<iostream>  
#include<fstream>  
#include<iomanip>  
#include<cstdio>  
#include<cstdlib>  
#include<algorithm>  
#include<cmath>  
using namespace std;  

const int N=200005;

struct Point{  
	double x,y;  
	Point(double x=0,double y=0):x(x),y(y){ }
	friend double dist(Point p1,Point p2){  
		return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));  
	}   
}p[N];
  
struct event{  
	double x; int f;
	bool operator < (const event &B) const {
		return x==B.x?f>B.f:x<B.x;
	}
}eve[N];  
int n,tot,ans;  

int main(){
	freopen("t.in","r",stdin);
	freopen("t.out","w",stdout);  
	while(scanf("%d",&n) && n){  
		for(int i=0;i<n;i++)  
			scanf("%lf%lf",&p[i].x,&p[i].y);  
		ans=1;  
		for(int i=0;i<n;i++){  
			tot=0;  
			for(int j=0;j<n;j++){  
				if(i==j) continue;  
				if(dist(p[i],p[j])>2.0) continue;  
				double x=atan2(p[i].y-p[j].y,p[i].x-p[j].x);  
				double phi=acos(dist(p[i],p[j])/2);  
				eve[tot].x=x-phi; eve[tot++].f=1;  
				eve[tot].x=x+phi; eve[tot++].f=-1;  
			}  
			sort(eve,eve+tot);  
			int tmp=1;  
			for(int i=0;i<tot;i++){  
				tmp+=eve[i].f;   
				ans=max(ans,tmp);  
			}  
		}  
		printf("%d\n",ans);  
	}
	return 0;  
}  


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值