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. linux bash算术运算

    +, -, *(乘), /(除), **(乘方), %(取模) let var=算术运算符表达式 var=$[算术运算符表达式] var=$((算术运算符表达式)) var=$(expr $ARG1 ...

  2. python条件变量之生产者与消费者操作实例分析

    python条件变量之生产者与消费者操作实例分析 本文实例讲述了python条件变量之生产者与消费者操作.分享给大家供大家参考,具体如下: 互斥锁是最简单的线程同步机制,面对复杂线程同步问题,Pyth ...

  3. 常用命令5--文件搜索命令3-find

    发现没有出来install.log.syslog ,find不能进行模糊搜索.要想模糊搜索,必须用通配符. 没有所有者的文件是垃圾文件.但是内核产生文件,在这两个文件夹里文件有可能没有所有者,很正常, ...

  4. linux基础指令参数

    eth0,eth1,eth2--代表网卡一,网卡二,网卡三-- lo代表127.0.0.1,即localhost 参考: Linux命令:ifconfig 功能说明:显示或设置网络设备 语 法:ifc ...

  5. select2 如何自定义提示信息-布布扣-bubuko.com

    标签:color   dom   layui   href   默认事件   替换   each   ase   options 最近项目中使用到了select2来美化和丰富下拉框的功能,这款插件功能 ...

  6. caffe 的docker安装过程及相关linux操作总结

    一.caffe 和 docker的安装编译 docker pull caffe镜像(注意使用docker安装省去安装CUDA和cudnn的安装.) 安装相关依赖包 安装opencv3(使用源码安装) ...

  7. const、引用与指针

    前提 我们忽略掉了相同类型是否可以赋值的情况(我到现在的学习里都还可以相互赋值),以及类型兼容的情况.只考虑const.&.*等修饰符带来的影响 类型兼容: 强制类型转换 基类与子类间的兼容 ...

  8. 【水滴石穿】rn_statusbar

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

  9. layui的select联动 - CSDN博客

    要实现联动效果注意两点: 第一要可以监听到select的change事件: 第二异步加载的内容,需要重新渲染后才可以 正常使用. html结构: <form class="layui- ...

  10. Mathematica 和 MATLAB、Maple 并称为三大数学软件

    Mathematica是一款科学计算软件,很好地结合了数值和符号计算引擎.图形系统.编程语言.文本系统.和与其他应用程序的高级连接.很多功能在相应领域内处于世界领先地位,它也是使用最广泛的数学软件之一 ...