题意略。

思路:

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

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

详见代码:

#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. 头部姿态估计 - OpenCV/Dlib/Ceres

    基本思想 通过Dlib获得当前人脸的特征点,然后通过旋转平移标准模型的特征点进行拟合,计算标准模型求得的特征点与Dlib获得的特征点之间的差,使用Ceres不断迭代优化,最终得到最佳的旋转和平移参数. ...

  2. Git学习(二):Git的初步使用

    一.Git的最小配置 1.使用如下命令创建Git的用户名和邮箱,如下所示: $git config --global user.name 'your_name' $git config --globa ...

  3. PointCloud及其经典论文介绍

    这篇博客会介绍点云的基本知识,重点介绍最近两年发表的部分经典论文,有什么建议欢迎留言! 点云基本介绍 点云是某个坐标系下的点的数据集,包含了丰富的信息,可以是三维坐标X,Y,Z.颜色.强度值.时间等等 ...

  4. jsp的简介(1)

    一.什么是Java Server Pages? JSP全称Java Server Pages,是一种动态网页开发技术.它使用JSP标签在HTML网页中插入Java代码.标签通常以<%开头以%&g ...

  5. linuk下proftpd安装

    Linux下Proftpd安装与配置 1.下载 下载地址:ftp://ftp.proftpd.org/distrib/source/proftpd-1.3.6rc1.tar.gz 文件下载到/soft ...

  6. Python装饰器 (转)

    多个装饰器执行的顺序就是从最后一个装饰器开始,执行到第一个装饰器,再执行函数本身. #多个装饰器 import time def deco01(func): def wrapper(*args, ** ...

  7. angular6组件封装以及发布到npm

    一.创建angular项目 ng new myFirstDemo //angular-cli新建项目ng g m testm //新建模块ng g c testm/headertest //新建组件 ...

  8. 派胜OA二次开发笔记(1)重写主界面

    最近从派胜OA 2018 升级到 2019,为了二次开发方便,索性花了两天,反向分析 PaiOA 2019 主界面程序,重写大部分代码,方便对菜单权限进行控制. 主界面/core/index.aspx ...

  9. FTP工具-FileZilla安装使用教程

    1.首先,百度搜索“FileZilla”,进入官网,下载地址:https://www.filezilla.cn/download/client  ,根据自己电脑配置去下载 2.下载本地,双击运行安装程 ...

  10. HTML之必备meta标签

    meta标签写在HTML的<head>中,推荐每个手机H5页面必加以下的代码: <head> <meta charset="UTF-8"> &l ...