codeforces 814D An overnight dance in discotheque(思维)
来源:互联网 发布:长城网络还原大师卸载 编辑:程序博客网 时间:2024/05/20 22:03
题意:给你一个坐标轴,里面有一些圆,在这个圆的覆盖区域中如果有奇数个圆覆盖就加上这块覆盖区域,如果有偶数个圆覆盖就减去这块区域,现在可以将
这个平面一分为2,求最大的区域和;
题解:这道题表面上是求最优解问题,实际上是答案是个定值,仔细想一想,首先从最简单的情况分解问题
如果是这个圆的话没有被别的圆覆盖的话就加上,如果这个圆被一个圆覆盖的话也加上,相当于把他放到第二个平面中,如果放到第一个平面中就是减去,但是被他覆盖的
所有圆的面积加起来都比他小(只考虑比当前层数小的一层,嵌套覆盖的情况按照这个思路考虑),相当于每次都把面积大的那个保留了下来
#include<cstdio>#include<cstdlib>#include<cstring>#include<iostream>#include<cmath>#include <bits/stdc++.h>using namespace std;const int N = 3e5+10;typedef long long LL;struct node{ double x, y, r;}p[N];double dist(int a,int b){ return sqrt((p[a].x-p[b].x)*(p[a].x-p[b].x)+(p[a].y-p[b].y)*(p[a].y-p[b].y));}const double pi=acos(-1.0);int main(){ int n; scanf("%d", &n); for(int i=1;i<=n;i++) scanf("%lf %lf %lf",&p[i].x,&p[i].y,&p[i].r); double ans=0; for(int i=1;i<=n;i++) { int cnt=0; for(int j=1;j<=n;j++) { if(i==j) continue; double d=dist(i,j); if(d<p[j].r&&p[j].r>p[i].r) cnt++; } if(cnt%2==0&&cnt!=0) ans-=p[i].r*p[i].r; else ans+=p[i].r*p[i].r; } printf("%.10f\n",ans*pi); return 0;}
阅读全文
0 0
- codeforces 814D An overnight dance in discotheque(思维)
- Codeforces 814D An overnight dance in discotheque【思维】
- codeforces D. An overnight dance in discotheque
- codeforces 814D An overnight dance in discotheque
- Codeforces 814D An overnight dance in discotheque DP(树形)
- Codeforces 814D-An overnight dance in discotheque
- codeforces 814 D An overnight dance in discotheque
- codeforces 814D An overnight dance in discotheque(贪心)
- Codeforces 814D-An overnight dance in discotheque 贪心
- Codeforces-814D An overnight dance in discotheque(贪心)
- codeforces 814D An overnight dance in discotheque(几何思维)
- Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque(思维 贪心)
- D. An overnight dance in discotheque
- coderforces 814 D. An overnight dance in discotheque(贪心)
- [Codeforces 814D] An overnight dance in discotheque 树形dp,贪心
- CF#418 Div2 D. An overnight dance in discotheque
- Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque
- Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque 贪心
- 怎样玩转千万级别的数据(表分区)
- 使用gcov生成增量覆盖率报告
- google翻译API
- Android多进程app中Application回调onCreate()方法被执行多次分析及解决
- mysql的DATE_FORMAT参数格式
- codeforces 814D An overnight dance in discotheque(思维)
- css遮罩层
- 淘淘商城系列——商品搜索功能Service实现
- 5月Qoo10美容化妆品类目月销量276,820,你该如何选品?
- Quartz克龙表达式
- tomcat配置
- 逻辑数据库设计
- 怎么做到微信直播,HTML5直播,低延时
- 打造一个自动化的前端项目