Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque
来源:互联网 发布:java 时间段 拆分 编辑:程序博客网 时间:2024/05/17 23:45
http://codeforces.com/contest/814/problem/D
题意:给你n个圆的坐标和半径
你将n个圆分为两部分
每部分中的圆若被覆盖了奇数次需要减去 偶数次需要加上
思路:贪心
先把没有被覆盖圆放入上半场
再把剩下的圆放入下半场
计算两者的面积和
ACcode:
#include<bits/stdc++.h>using namespace std;const int maxn = 1100;const double eps = 1e-9;const double pi = acos(-1.0);struct node{ double x, y, r; node(double xx = 0.0, double yy = 0.0, double rr = 0.0) : x(xx), y(yy), r(rr) {}} del[maxn];int cheak(int a, int b){ double ret1 = (del[a].x - del[b].x) * (del[a].x - del[b].x) + (del[a].y - del[b].y) * (del[a].y - del[b].y); double ret2 = (del[a].r + del[b].r) * (del[a].r + del[b].r); if((ret1 - ret2) < 0 && (del[a].r - del[b].r) > 0) return 1; else return 0;}int iv[maxn];int main(){ int n; scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%lf%lf%lf", &del[i].x, &del[i].y, &del[i].r); for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { if(i == j) continue; if(cheak(i,j) == 1) iv[j]++; } } double ans = 0.0; for(int i=1;i<=n;i++) { //printf("i %d del %f %f %f iv %d\n",i,del[i].x, del[i].y, del[i].r,iv[i]); if(iv[i] == 0 || iv[i] % 2 == 1) ans+=del[i].r*del[i].r*pi;///删除没有被覆盖的圆后 下半场的奇偶互换 else ans-=del[i].r*del[i].r*pi; ans+=eps; ans-=eps; } printf("%.9f\n",ans); return 0;}
阅读全文
0 0
- Codeforces Round #418 (Div. 2) 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 贪心
- codeforces 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 DP(树形)
- Codeforces 814D-An overnight dance in discotheque
- 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(贪心)
- D. An overnight dance in discotheque
- CF#418 Div2 D. An overnight dance in discotheque
- coderforces 814 D. An overnight dance in discotheque(贪心)
- [Codeforces 814D] An overnight dance in discotheque 树形dp,贪心
- codeforces 814D An overnight dance in discotheque(几何思维)
- SDUT-1131 最大公约数与最小公倍数
- 设置mysql 表名不区分大小写
- Android自定义Notification通知
- Android studio2.4的新特性
- vue.js学习03之组件
- Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque
- java源代码加密+使用proguard混淆java web项目代码+自定义Classloader
- 爱思华宝 IceWarp V12 拥有无限可能的企业电子邮件及协作平台
- FL2440添加DS18B20驱动
- Hrbust 1329 Leyni, 罗莉 与 游乐场【树型Dp+思维】好题!
- C++智能指针
- 如何在HTTP头中隐藏php的头号
- Ajax 使用 FormData做为data的参数时 出现Illegal invocation
- svn“Previous operation has not finished; run 'cleanup' if it was interrupted“报错的解决方法