题意略。

思路:

由于不重合这个性质,我们可以将每一个堆叠的圆圈单独拿出来考虑,而不用去考虑其他并列在同一层的存在,

在贪心解法下,发现,被嵌套了偶数层的圆圈永远是要被减去的,而奇数层的圆圈是要加上的。

详见代码:

#include<bits/stdc++.h>
#define maxn 1005
#define eps 1e-8
#define pi acos(-1.0)
using namespace std; struct Circle{
double x,y,r;
Circle(double a = ,double b = ,double c = ){
x = a,y = b,r = c;
}
double area(){
return r * r * pi;
}
}; Circle store[maxn];
int mark[maxn];
int n; double dist(int c1,int c2){
double x1 = store[c1].x,y1 = store[c1].y;
double x2 = store[c2].x,y2 = store[c2].y;
double dx = x1 - x2,dy = y1 - y2;
return sqrt(dx * dx + dy * dy);
}
int sgn(double x,double y){
if(fabs(x - y) < eps) return ;
else if(x > y + eps) return ;
else return -;
}
bool in(int x,int y){
double r = fabs(store[x].r - store[y].r);
double d = dist(x,y);
if(sgn(d,r) <= ) return true;
return false;
}
bool cmp(const Circle& c1,const Circle& c2){
return c1.r > c2.r;
} int main(){
scanf("%d",&n);
for(int i = ;i < n;++i){
scanf("%lf%lf%lf",&store[i].x,&store[i].y,&store[i].r);
}
sort(store,store + n,cmp);
for(int i = ;i < n;++i){
int cnt = ;
for(int j = ;j < i;++j){
if(in(i,j)) ++cnt;
}
mark[i] = cnt;
}
double ans = ;
for(int i = ;i < n;++i){
if(mark[i] == ) ans += store[i].area();
else if(mark[i] & ) ans += store[i].area();
else ans -= store[i].area();
}
printf("%.9lf\n",ans);
return ;
}

Codeforces 814D的更多相关文章

  1. An overnight dance in discotheque CodeForces - 814D (几何)

    大意: 给定n个不相交的圆, 求将n个圆划分成两部分, 使得阴影部分面积最大. 贪心, 考虑每个连通块, 最外层大圆分成一部分, 剩余分成一部分一定最优. #include <iostream& ...

  2. CodeForces 814D An overnight dance in discotheque(贪心+dfs)

    The crowdedness of the discotheque would never stop our friends from having fun, but a bit more spac ...

  3. codeforces 814D An overnight dance in discotheque

    题目链接 正解:贪心. 首先我们可以计算出每个圆被多少个圆覆盖. 很显然,最外面的圆是肯定要加上的. 然后第二层的圆也是要加上的.那么第三层就不可能被加上了.同理,第四层的圆又一定会被加上. 然后我们 ...

  4. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  5. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  6. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  7. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  8. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  9. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

随机推荐

  1. 从0系统学Android-2.4隐式Intent

    本系列文章,参考<第一行代码>,作为个人笔记 更多内容:更多精品文章分类 使用隐式 Intent 相对于显示 Intent ,隐式 Intent 比较含蓄.这种方式不明确指出我们想要启动哪 ...

  2. CMS简单内容管理系统

    架构 NewsDaoSQLServerImpl public class NewsDaoSQLServerImpl extends BaseDao implements NewsDao { publi ...

  3. ES 22 - Elasticsearch中如何进行日期(数值)范围查询

    目录 1 范围查询的符号 2 数值范围查询 3 时间范围查询 3.1 简单查询示例 3.2 关于时间的数学表达式(date-math) 3.3 关于时间的四舍五入 4 日期格式化范围查询(format ...

  4. 网站性能优化的方法--Yahoo

    如何能让用户更快的打开我们的网页? 1.尽可能减少HTTP请求数 2.使用CDN(内容分发网络) 3.添加Expire/Cache-Control头 4.启用Gzip压缩 5.将CSS放在页面最上面 ...

  5. html以前没有学到的标签

    <q>标签,短文本引用 <blockquote>标签,长文本引用 <address>标签,为网页加入地址信息 <code>标签,插入单行代码 <p ...

  6. 8天入门docker系列 —— 第八天 让程序跑在swarm集群上

    真正的落地部署都是希望程序跑在集群下,而不是单机版下测测玩玩,所以这篇就来聊一下怎么使用docker swarm进行部署,因为是swarm是docker自带的, 所以部署起来还是非常简单的. 一:前置 ...

  7. 定时延时设计FPGA

    以50MHZ时钟为例,进行1秒钟延时,并输出延时使能信号. 首先计算需要多少次计时,MHZ=10的六次方HZ.T=20ns 一秒钟需要计时次数为5的七次方即5000_0000. 然后计算需要几位的寄存 ...

  8. 从源码看java线程状态

    关于java线程状态,网上查资料很混乱,有的说5种状态,有的说6种状态,初学者搞不清楚这个线程状态到底是怎么样的,今天我讲一下如何看源码去解决这个疑惑. 直接上代码: public class Thr ...

  9. JavaSE(二)标识符,关键字,数据类型

    一.标识符和关键字         1.具有特殊作用的分隔符:分号;.花括号{}.圆括号().空格.圆点 .          2.标识符规则:用于给程序中变量.类.方法命名的符号.       Ja ...

  10. C#文件下载流程

    private bool DownloadPicture(string picUrl, string savePath, int timeOut)         {             bool ...