Problem - 1077

  我们可以知道,当这个单位圆可以覆盖到最多的点的时候,必定最少有两个点位于这个圆的圆周上,于是就有网上众多的O(N^3)的枚举两个在圆上的点的暴搜做法。

  然而这题是可以用圆交来做的。

  我们以一条鱼的位置作为圆心,半径为1的圆的周围随便找一个点都能把这条鱼抓到。这时,我们可以做出很多个这样的圆,半径都为1。

  然后,求一下这些圆的交集,叠起来的最高层数就是最多能获得的鱼的数目。

  这里的圆交不需要实现求面积这部分,于是只需要离散一下交点就行了。

  1y。

 #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath> using namespace std; const double EPS = 1e-;
const double PI = acos(-1.0);
inline int sgn(double x) { return (x > EPS) - (x < -EPS);}
template<class T> T sqr(T x) { return x * x;}
typedef pair<double, double> Point;
#define x first
#define y second Point operator + (Point a, Point b) { return Point(a.x + b.x, a.y + b.y);}
Point operator - (Point a, Point b) { return Point(a.x - b.x, a.y - b.y);}
Point operator * (Point a, double p) { return Point(a.x * p, a.y * p);}
Point operator * (double p, Point a) { return Point(a.x * p, a.y * p);}
Point operator / (Point a, double p) { return Point(a.x / p, a.y / p);} inline double cross(Point a, Point b) { return a.x * b.y - a.y * b.x;}
inline double dot(Point a, Point b) { return a.x * b.x + a.y * b.y;}
inline double veclen(Point a) { return sqrt(dot(a, a));}
inline double angle(Point a) { return atan2(a.y, a.x);}
inline Point vecunit(Point a) { return a / veclen(a);}
inline Point normal(Point a) { return Point(-a.y, a.x) / veclen(a);} struct Line {
Point s, t;
Line() {}
Line(Point s, Point t) : s(s), t(t) {}
Point vec() { return t - s;}
Point point(double p) { return s + vec() * p;}
} ;
inline Point llint(Line a, Line b) { return a.point(cross(b.vec(), a.s - b.s) / cross(a.vec(), b.vec()));} struct Circle {
Point c;
double r;
Circle() {}
Circle(Point c, double r) : c(c), r(r) {}
Point point(double p) { return c + r * Point(cos(p), sin(p));}
bool in(Point p) { return sgn(veclen(p - c) - r) < ;}
} ; const double R = 1000.0;
const int N = ;
int n;
Circle cir[N]; void input() {
cin >> n;
for (int i = ; i < n; i++) {
cin >> cir[i].c.x >> cir[i].c.y;
cir[i].c = cir[i].c * R;
cir[i].r = R;
}
} bool ccint(int _a, int _b, double *sol) {
Circle a = cir[_a], b = cir[_b];
double d = veclen(a.c - b.c), dr = fabs(a.r - b.r);
if (sgn(d - a.r - b.r) > ) return ;
if (sgn(dr - d) >= ) {
if (a.r < b.r || sgn(a.r - b.r) == && _a < _b) {
sol[] = -PI;
sol[] = PI;
return ;
}
return ;
}
double ang = angle(b.c - a.c);
double da = acos(fabs(sqr(a.r) + sqr(d) - sqr(b.r)) / ( * a.r * d));
sol[] = ang - da;
sol[] = ang + da;
return ;
} typedef pair<double, int> Event;
Event ev[N << ];
bool cmp(Event a, Event b) {
if (sgn(a.x - b.x)) return a.x < b.x;
return a.y > b.y;
} int cal(int id) {
int tt = ;
double _[];
for (int i = ; i < n; i++) {
if (i == id) continue;
if (ccint(id, i, _)) {
if (_[] < -PI) {
ev[tt++] = Event(_[] + * PI, );
ev[tt++] = Event(PI, -);
ev[tt++] = Event(-PI, );
ev[tt++] = Event(_[], -);
} else if (_[] > PI) {
ev[tt++] = Event(_[], );
ev[tt++] = Event(PI, -);
ev[tt++] = Event(-PI, );
ev[tt++] = Event(_[] - * PI, -);
} else {
ev[tt++] = Event(_[], );
ev[tt++] = Event(_[], -);
}
}
}
int cnt = , mx = ;
sort(ev, ev + tt, cmp);
for (int i = ; i < tt; i++) {
cnt += ev[i].y;
mx = max(mx, cnt);
}
return mx;
} int work() {
int mx = ;
for (int i = ; i < n; i++) mx = max(mx, cal(i));
return mx;
} int main() {
//freopen("in", "r", stdin);
ios::sync_with_stdio();
cout << setiosflags(ios::fixed) << setprecision();
int _;
cin >> _;
while (_--) {
input();
cout << work() << endl;
}
return ;
}

——written by Lyon

hdu 1077 (圆交)的更多相关文章

  1. HDU 3467 Song of the Siren(圆交)

    Problem Description In the unimaginable popular DotA game, a hero Naga Siren, also known as Slithice ...

  2. 计算几何(容斥原理,圆交):HDU 5120 Intersection

    Matt is a big fan of logo design. Recently he falls in love with logo made up by rings. The followin ...

  3. HDU 3264 Open-air shopping malls ——(二分+圆交)

    纯粹是为了改进牛吃草里的两圆交模板= =. 代码如下: #include <stdio.h> #include <algorithm> #include <string. ...

  4. Intersection(HDU5120 + 圆交面积)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5120 题目: 题意: 求两个圆环相交的面积. 思路: 两个大圆面积交-2×大圆与小圆面积交+两小圆面 ...

  5. CF 337D 求圆交

    题目链接:http://codeforces.com/problemset/problem/337/D 题意:就是一棵树上,有一些点被来自东方的神秘力量影响的,力量影响范围是d,为可能的力量源有几个. ...

  6. hdu 5700区间交(线段树)

    区间交 Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submiss ...

  7. HDU 3511 圆扫描线

    找最深的圆,输出层数 类似POJ 2932的做法 圆扫描线即可.这里要记录各个圆的层数,所以多加一个维护编号的就行了. /** @Date : 2017-10-18 18:16:52 * @FileN ...

  8. hdu 6010 路径交

    hdu 6010 路径交(lca + 线段树) 题意: 给出一棵大小为\(n\)的树和\(m\)条路径,求第\(L\)条路径到第\(R\)条路径的交的路径的长度 思路: 本题的关键就是求路径交 假设存 ...

  9. hdu 3264 圆的交+二分

    Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/ ...

随机推荐

  1. npm常用命令及版本号

    npm 包管理器的常用命令 测试环境为node>=8.1.3&&npm>=5.0.3 1, 首先是安装命令 //全局安装 npm install 模块名 -g //本地安装 ...

  2. Codeforces Round #573 (Div. 2)

    A:Tokitsukaze and Enhancement 当时看错条件了..以为A>C>B>D.就胡写了判断条件. #include<bits/stdc++.h> us ...

  3. Liferay 7.1发布啦

    下载地址: https://cdn.lfrs.sl/releases.liferay.com/portal/7.1.0-m1/liferay-ce-portal-tomcat-7.1-m1-20180 ...

  4. web前端学习(二)html学习笔记部分(5)--拖放元素、canvas画布使用

    1.2.11  拖放 1.2.11.1  html拖放 1.2.11.2  html拖放本次资源 showOjb(一个对象)展示一下一个对象的信息. 1.2.12  html画布(canvas)  标 ...

  5. springboot-mybatis双数据源配置

    yml文件 spring: datasource: test1: driverClassName: com.mysql.jdbc.Driver url: jdbc:mysql://localhost: ...

  6. tomcat配置证书

    [size=x-small][size=xx-large][size=medium] 1.利用java 生成一个.keystore文件 进入命令行(假设已经设定了环境变量) 执行 keytool -g ...

  7. 详细介绍Java中的堆、栈和常量池

    下面主要介绍JAVA中的堆.栈和常量池: 1.寄存器 最快的存储区, 由编译器根据需求进行分配,我们在程序中无法控制. 2. 栈 存放基本类型的变量数据和对象的引用,但对象本身不存放在栈中,而是存放在 ...

  8. NOIP模拟 17.8.17

    NOIP模拟17.8.17 A 小 G 的字符串文件名 输入文件 输出文件 时间限制 空间限制str.pas/c/cpp str.in str.out 1s 128MB[题目描述]有一天,小 L 给小 ...

  9. 【水滴石穿】rn_statusbar

    先放项目地址https://github.com/hezhii/rn_statusbar 来看一下效果 咩有感觉很怎么样,看代码 根入口文件 //index.js //看代码我们知道入口是app.js ...

  10. 阿里云MVP北京闭门会圆满落幕 多把“利剑”助力开发者破阵蜕变

    摘要: 从传统制造业到新零售,从人工智能到新金融,阿里云MVP正在成为中国乃至全球各行各业数字化转型的中坚力量.当这群技术先锋者与阿里核心技术力量汇聚在一起,一场无与伦比的思想碰撞就此展开. 3月21 ...