计算几何真的好暴力啊。

#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define max(a,b) (a) > (b) ? (a) : (b)
#define N 1003
using namespace std;
const double Pi = acos(-1);
inline int dcmp(double x) {return (fabs(x) < 1e-6) ? 0 : (x < 0 ? -1 : 1);}
inline double sqr(double x) {return x * x;}
struct Point {
double x, y;
Point(double _x = 0, double _y = 0) : x(_x), y(_y) {}
};
struct Rround {
Point O; double R;
Rround(Point _O = Point(0, 0), double _R = 0) : O(_O), R(_R) {}
};
Point operator - (Point a, Point b) {return Point(a.x - b.x, a.y - b.y);}
inline double dis(Rround a, Rround b) {return sqrt(sqr(a.O.x - b.O.x) + sqr(a.O.y - b.O.y));}
inline bool cover(Rround to, Rround now) {return to.R >= now.R + dis(to, now);}
struct Splay {
double l, r;
Splay(double _l = 0, double _r = 0) : l(_l), r(_r) {}
}; Splay s[N];
int n, top;
double ans = 0, tt, nxt;
Rround r[N];
bool pd; inline void ins(Rround a, Rround b) {
double d = dis(a, b), t, st, l;
t = (sqr(a.R) - sqr(b.R) + sqr(d)) / (d + d);
st = atan2((a.O.y - b.O.y), (a.O.x - b.O.x));
//st = atan2((a.O.x - b.O.x), (a.O.y - b.O.y));
l = acos(t / a.R);
s[++top] = Splay(st - l, st + l);
}
inline bool cmp(Splay a, Splay b) {return a.l < b.l;} int main() {
scanf("%d", &n);
for(int i = 1; i <= n; ++i)
scanf("%lf%lf%lf", &r[i].R, &r[i].O.x, &r[i].O.y); for(int i = 1; i <= n; ++i) {
pd = 0;
for(int j = i + 1; j <= n; ++j)
if (cover(r[j], r[i])) {
pd = 1;
break;
}
if (pd)
continue; top = 0;
for(int j = i + 1; j <= n; ++j)
if (!cover(r[i], r[j]) && r[i].R + r[j].R >= dis(r[i], r[j]))
ins(r[i], r[j]); for(int j = 1; j <= top; ++j) {
if (s[j].l < 0) s[j].l += 2 * Pi;
if (s[j].r < 0) s[j].r += 2 * Pi;
if (s[j].l > s[j].r) {
s[++top] = Splay(0, s[j].r);
s[j].r = 2 * Pi;
}
} sort(s + 1, s + top + 1, cmp); tt = 0; nxt = 0;
for(int j = 1; j <= top; ++j)
if (s[j].l > nxt) {
tt += s[j].l - nxt;
nxt = s[j].r;
} else
nxt = max(nxt, s[j].r);
tt += 2 * Pi - nxt; ans += tt * r[i].R;
} printf("%.3lf\n",ans);
return 0;
}

可惜一开始$π$设为$int$了查了$2h$的错QAQ横坐标相减打错查了$1h+$TWT

【BZOJ 1043】【HNOI 2008】下落的圆盘 判断圆相交+线段覆盖的更多相关文章

  1. [bzoj 1004][HNOI 2008]Cards(Burnside引理+DP)

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1004 分析: 1.确定方向:肯定是组合数学问题,不是Polya就是Burnside,然后题目上 ...

  2. BZOJ 1009 HNOI 2008 GT考试 递推+矩乘

    1009: [HNOI2008]GT考试 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 3679  Solved: 2254[Submit][Statu ...

  3. [bzoj 1005][HNOI 2008]明明的烦恼(prufer数列+排列组合)

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1005 分析: 首先prufer数列:http://baike.baidu.com/view/1 ...

  4. BZOJ 1007 HNOI 2008 水平可见直线 计算几何+栈

    题目大意:给出一些笛卡尔系中的一些直线,问从(0,+∞)向下看时能看到哪些直线. 思路:半平面交可做,可是显然用不上. 类似于求凸包的思想,维护一个栈. 先将全部直线依照k值排序.然后挨个压进去,遇到 ...

  5. [bzoj 1010][HNOI 2008]玩具装箱

    传送门 Description P教授要去看奥运,但是他舍不下他的玩具,于是他决定把所有的玩具运到北京.他使用自己的压缩器进行压 缩,其可以将任意物品变成一堆,再放到一种特殊的一维容器中.P教授有编号 ...

  6. [bzoj] 1043 下落的圆盘 || 圆上的“线段覆盖”

    原题 n个圆盘,求下落后能看到的总周长. 红色即为所求 借鉴于黄学长的博客 对于每下落的一个圆盘,处理他后面的圆盘会挡住哪些区域,然后把一整个圆(2\(/pi\))当做一整个区间,每个被覆盖的部分都可 ...

  7. bzoj 1043 下落的圆盘 —— 求圆心角、圆周长

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1043 求出每个圆没被覆盖的长度即可: 特判包含和相离的情况,注意判包含时 i 包含 j 和 ...

  8. 1043: [HAOI2008]下落的圆盘

    Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1725  Solved: 743[Submit][Status][Discuss] Descripti ...

  9. BZOJ1043:[HAOI2008]下落的圆盘——题解(配图片)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1043 Description 有n个圆盘从天而降,后面落下的可以盖住前面的.求最后形成的封闭区域的周 ...

随机推荐

  1. NOIP2003传染病控制[按层DFS]

    题目背景 近来,一种新的传染病肆虐全球.蓬莱国也发现了零星感染者,为防止该病在蓬莱国大范围流行,该国政府决定不惜一切代价控制传染病的蔓延.不幸的是,由于人们尚未完全认识这种传染病,难以准确判别病毒携带 ...

  2. using关键字的用法

    1.using 关键字可以用来导命名空间,与java中的import类似. 2.using关键字可以用来释放资源,并且被释放的资源代码是非托管代码. 既然可以释放非托管代码,那么什么是非托管代码? 我 ...

  3. 网页动物园2.0发布,经过几个月的努力,采用JAVA编写!

    网页动物园2.0发布,经过几个月的努力,采用JAVA编写! 网页动物园2.0 正式发布!游戏发布 游戏名称: 网页动物园插件 游戏来源: 原创插件 适用版本: Discuz! X1.5 - X3.5 ...

  4. div根据内容改变大小并且左右居中

    div{ display:inline-block; width:auto; } 这个div的父元素text-align:center;

  5. tyvj[1089]smrtfun

    描述  现有N个物品,第i个物品有两个属性A_i和B_i.在其中选取若干个物品,使得sum{A_i + B_i}最大,同时sum{A_i},sum{B_i}均非负(sum{}表示求和). 输入格式   ...

  6. iOS 使用证书时遇到的错误一

    证书概念: 那么现在就牵扯到几个名词,Development证书,aps_Development证书(推送证书),测试描述文件,AppID,同理也就有Distribution证书,aps_Distri ...

  7. ASP.NET常用页面指令

    1.<%@Page "属性"="值"%>指令 AutoEventWireup:指定页的事件是否自动绑定,默认值true为启用自动绑定. CodeBe ...

  8. ajax asud模板

    <table class="table"> <tr> <th>@Html.DisplayNameFor(model=>model.Id)& ...

  9. Net中HttpClient 重试

    /// <summary>         /// 重试         /// </summary>         public class RetryHandler : ...

  10. linux运维中的命令梳理(二)

    回想起来,从事linux运维工作已近5年之久了,日常工作中会用到很多常规命令,之前简单罗列了一些命令:http://www.cnblogs.com/kevingrace/p/5985486.html今 ...