Codeforces 814D-An overnight dance in discotheque 贪心
来源:互联网 发布:apache配置文件路径 编辑:程序博客网 时间:2024/06/15 18:53
参考http://blog.csdn.net/a664607530/article/details/72921758
题意:就是告诉你有n个圆(跳舞),告诉你圆心和半径,圆两两之间不会有多余一个的交点,所以两圆之间要不是相离要不是内含。有上半场和下半场之分,每个圆只能出现一次,圆不能包含另一个圆,如果一个人跳舞被覆盖奇数次,他的面积就需要被减去,被覆盖偶数次他的面积就会被加上,然后现在问你跳舞合适的最大面积是多少。
解题思路:把所有圈圈被覆盖的次数统计一下,最大那个肯定加,然后奇数大的加进去,偶数大的减掉,最大的可以在上半夜跳,然后奇数大的在下半夜跳
int n; double ans; struct node { double x, y, r; int flag; }a[1001]; bool cmp(node a, node b) { if (a.r == b.r) return a.x == b.x ? a.y < b.y : a.x < b.x; return a.r > b.r; } bool check(node a, node b) { return (a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y) < (a.r + b.r)*(a.r + b.r); } int main() { while (~scanf("%d", &n)) { for (int i = 1; i <= n; i++) scanf("%lf%lf%lf", &a[i].x, &a[i].y, &a[i].r), a[i].flag = 0; sort(a + 1, a + n + 1, cmp); for (int i = 1; i < n; i++) for (int j = i + 1; j <= n; j++) if (check(a[i], a[j])) a[j].flag++; for (int i = 1; i <= n; i++) { if (!a[i].flag) ans += a[i].r*a[i].r*pi; else if (a[i].flag % 2) ans += a[i].r*a[i].r*pi; else ans -= a[i].r*a[i].r*pi; } printf("%.8lf\n", ans); } return 0; }
阅读全文
0 0
- codeforces 814D An overnight dance in discotheque(贪心)
- Codeforces 814D-An overnight dance in discotheque 贪心
- Codeforces-814D An overnight dance in discotheque(贪心)
- codeforces D. An overnight dance in discotheque
- coderforces 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 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 树形dp,贪心
- Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque(思维 贪心)
- Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque 贪心
- D. An overnight dance in discotheque
- codeforces 814D An overnight dance in discotheque(几何思维)
- 贪心——Codeforces814D An overnight dance in discotheque
- CF#418 Div2 D. An overnight dance in discotheque
- 多线程编程---python
- Ubuntu 14.04设置默认root 用户
- 【转】SAP LIST 画框的FORM
- linux:使用comm命令比较两个文件:交集、差
- git Windows安装
- Codeforces 814D-An overnight dance in discotheque 贪心
- log4cxx
- 拓展欧几里得算法
- Spring "@Autowired" 注解注入值为空
- EL表达式和JSTL
- CWnd与HWND的区别与转换 如何获取本窗体对象
- python: str.format (字符串 格式化)
- 一个关于binder的debug技巧
- E