bzoj1338: Pku1981 Circle and Points单位圆覆盖
来源:互联网 发布:盘石网络 编辑:程序博客网 时间:2024/06/06 05:16
传送门
首先,最有解一定是有一个点恰好在圆上。
然后我们枚举那个在圆上的点
然后我们计算出当圆心绕该店旋转时,其他点能被覆盖的区间
然后大力线段覆盖一发就行了
时间复杂度O(N^2logN)
#include<bits/stdc++.h>using namespace std;struct P{double x,y;}p[505];struct data{ double t; int f; bool operator <(const data &b)const{ return t==b.t?f>b.f:t<b.t; }}b[1005];int n,ans,tot;double dis(P a,P b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}int main(){ 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 (dis(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(dis(p[i],p[j])/2); b[++tot]=(data){x-phi,1}; b[++tot]=(data){x+phi,-1}; } sort(b+1,b+tot+1); for (int i=1,tmp=1;i<=tot;i++) ans=max(ans,tmp+=b[i].f); } printf("%d\n",ans); }}
阅读全文
0 0
- BZOJ1338: Pku1981 Circle and Points单位圆覆盖
- bzoj1338: Pku1981 Circle and Points单位圆覆盖
- [极大化 极角排序] POJ 1981 Circle and Points & BZOJ 1338 Pku1981 Circle and Points单位圆覆盖
- Circle and Points----单位圆覆盖最多点
- JOJ 2109 && POJ 1981 Circle and Points 计算几何 单位圆覆盖问题
- POJ 1981 Circle and Points(单位圆覆盖n^3&&n^2lgn)
- poj 1981 Circle and Points(圆覆盖点问题)
- POJ1981Circle and Points【单位圆能覆盖的最多点】
- poj 1981 Circle and Points(固定半径的圆能覆盖的最多点数)
- POJ 1981 Circle and Points
- POJ 1981 Circle and Points(求半径R圆覆盖最多点数及由圆上两点和半径求圆心)
- zoj 2167 || poj 1981 Circle and Points
- 【计算几何】 POJ 1981 Circle and Points
- POJ 1981 Circle and Points 计算几何
- POJ 1981 Circle and Points 已翻译
- POJ1981 Circle and Points(计算几何)
- poj1981 Circle and Points 计算几何
- poj 1981 Circle and Points (模板)
- 输入一棵二叉树,求该树的深度。从根结点到叶结点依次经过的结点(含根、叶结点)形成树的一条路径,最长路径的长度为树的深度。
- JAVA 攻城狮 第二十九天
- 浅谈整体二分
- maven的模块xml配置
- iOS基础之路之addsubview和insertSubView
- bzoj1338: Pku1981 Circle and Points单位圆覆盖
- poj 3461
- 跨域源资源共享CORS
- 在 Linux 中如何自动批量创建用户
- Linux -自动安装系统
- (13)xml入门三
- C++之为“异常安全”而努力是值得的(29)---《Effective C++》
- Leetcode211. Add and Search Word
- 素数检测算法