HDU 3264 Open-air shopping malls ——(二分+圆交)
纯粹是为了改进牛吃草里的两圆交模板= =。
代码如下:
- #include <stdio.h>
- #include <algorithm>
- #include <string.h>
- #include <vector>
- #include <math.h>
- using namespace std;
- const int N = + ;
- typedef long long ll;
- const double eps = 1e-;
- const double pi = acos(-1.0);
- double inf = ;
- struct circle
- {
- double x,y,r;
- void read()
- {
- scanf("%lf%lf%lf",&x,&y,&r);
- }
- double calS()
- {
- return pi*r*r;
- }
- }c[];
- double myabs(double x) {return x < ? -x : x;}
- double get(circle c1,circle c2)
- {
- double a = c1.x, b = c1.y, R = c1.r;
- double x = c2.x, y = c2.y, r = c2.r;
- double dx = myabs(a-x), dy = myabs(b-y);
- double d = sqrt(dx*dx+dy*dy);
- if(d > R + r) return 0.0;
- if(R < r) swap(R,r);
- if(d < R-r) return pi*r*r;
- double A = 2.0*acos((R*R+d*d-r*r)/(2.0*R*d));
- double B = 2.0*acos((r*r+d*d-R*R)/(2.0*r*d));
- double s1 = 0.5*A*R*R + 0.5*B*r*r;
- double s2 = 0.5*R*R*sin(A) + 0.5*r*r*sin(B);
- return s1 - s2;
- }
- int n;
- bool solve(circle now)
- {
- for(int i=;i<=n;i++)
- {
- if(get(now,c[i]) >= 0.5*c[i].calS()) ;
- else return ;
- }
- return ;
- }
- int main()
- {
- int T;
- scanf("%d",&T);
- while(T--)
- {
- scanf("%d",&n);
- for(int i=;i<=n;i++) c[i].read();
- double ans = inf;
- for(int i=;i<=n;i++)
- {
- circle now = c[i];
- double L = , R = inf;
- int CNT = ;
- while(CNT--)
- {
- double mid = (L + R) / ;
- now.r = mid;
- if(solve(now)) R = mid;
- else L = mid;
- }
- ans = min(ans, R);
- }
- printf("%.4f\n",ans);
- }
- return ;
- }
HDU 3264 Open-air shopping malls ——(二分+圆交)的更多相关文章
- hdu 3264 Open-air shopping malls(圆相交面积+二分)
Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- HDU 3467 Song of the Siren(圆交)
Problem Description In the unimaginable popular DotA game, a hero Naga Siren, also known as Slithice ...
- HDU - 6167: Missile Interception (二分+圆的交)
pro:二维平面上,给点N个导弹的初始位置,射出方向,速度.问你是找一点,可以从这一点向任意方向发出拦截导弹,速度未V,最小化最大拦截导弹的时间. 如果要拦截一个导弹,必须在导弹发射之后才可以发射拦 ...
- hdu3264Open-air shopping malls(二分)
链接 枚举伞的圆心,最多只有20个,因为必须与某个现有的圆心重合. 然后再二分半径就可以了. #include <iostream> #include<cstdio> #inc ...
- hdu 3264 09 宁波 现场 E - Open-air shopping malls 计算几何 二分 圆相交面积 难度:1
Description The city of M is a famous shopping city and its open-air shopping malls are extremely at ...
- HDU 3264/POJ 3831 Open-air shopping malls(计算几何+二分)(2009 Asia Ningbo Regional)
Description The city of M is a famous shopping city and its open-air shopping malls are extremely at ...
- POJ 3831 & HDU 3264 Open-air shopping malls(几何)
题目链接: POJ:id=3831" target="_blank">http://poj.org/problem?id=3831 HDU:http://acm.h ...
- hdu 3264(枚举+二分+圆的公共面积)
Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- hdu 3264 圆的交+二分
Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
随机推荐
- java下载多个文件文件
第一步 将要下载的多个文件打包成ZIP格式 public String makeZip(List<String> path) throws IOException{ byte[] buff ...
- Override/implements methods 如何添加
用过Eclipse 的ADT的都知道,要快速添加override或者implements方法,右键---Source---Override/Implements Method... 中文:右键---& ...
- ubuntu上的mysql数据库双机备份设置
配置环境: myslq 5.5.3 + ubuntu server 12.04 一.配置MySQL主服务器(192.168.0.1) 1.增加一个账号专门用于同步 1 mysql>grant r ...
- jsonp的简单实现
jsonp: function(url, data, callback){ if( wfQuery.isFunction(data) ){ callback = data; data = {}; } ...
- eclipse快捷键(转载)
Ctrl+1 快速修复(最经典的快捷键,就不用多说了)Ctrl+D: 删除当前行 Ctrl+Alt+↓ 复制当前行到下一行(复制增加)Ctrl+Alt+↑ 复制当前行到上一行(复制增加)Alt+↓ 当 ...
- 【转】获取/设置IFRAME内对象元素的几种JS方法
1.IE专用(通过frames索引形象定位): document.frames[i].document.getElementById('元素的ID'); 2.IE专用(通过IFRAME名称形象定位): ...
- 查看光纤卡wwn号【转载】
转自:查看光纤卡wwn号windows操作系统下_朝晖_新浪博客http://blog.sina.com.cn/s/blog_4ce992f40101dxyv.html 查看光纤卡wwn号window ...
- springmvc json数据
的 @RequestMapping("/getAllEdu") @ResponseBody public void getAllEdu(HttpServletRequest req ...
- zf-关于查询机把index.jsp换成index_new.jsp页面之后把功能链接都改成新页面的简单方法
一开始我都是找action 然后一个一个的改 把onmousedown="goURL('index.jsp')" 改成 onmousedown="goURL('index ...
- 【学生成绩管理系统】 大二c语言作业
几年前写的了,只能在命令行窗口运行,虽然比较挫,还是有一定参考价值... #include <cstdio> #include <conio.h> #include <i ...