UVA 1473 - Dome of Circus(三分+计算几何)
来源:互联网 发布:青岛云优化工具 编辑:程序博客网 时间:2024/05/18 00:47
这题先推下公式,很容易发现圆锥的体积和半径满足一个二次函数,所以可以用三分
于是三分半径即可
代码:
#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const int N = 10005;const double PI = acos(-1.0);struct Point { double x, y, z; void read() { scanf("%lf%lf%lf", &x, &y, &z); }} p[N];int n;double gao(double r) { double h = 0; for (int i = 0; i < n; i++) { double d = sqrt(p[i].x * p[i].x + p[i].y * p[i].y); h = max(h, p[i].z / (r - d) * r); } return h;}int main() { while (~scanf("%d", &n)) { double l = 0, r = 1e20; for (int i = 0; i < n; i++) { p[i].read(); l = max(l, sqrt(p[i].x * p[i].x + p[i].y * p[i].y)); } l += 1e-8; for (int i = 0; i < 200; i++) { double midl = (l * 2 + r) / 3; double midr = (l + r * 2) / 3; double h1 = gao(midl); double h2 = gao(midr); double s1 = PI * midl / 3 * midl * h1; double s2 = PI * midr / 3 * midr * h2; if (s1 > s2) l = midl; else r = midr; } printf("%.3f %.3f\n", gao(l), l); } return 0;}
1 0
- UVA 1473 - Dome of Circus(三分+计算几何)
- HDU 3756 Dome of Circus(计算几何 + 三分)
- uva 1473 - Dome of Circus (几何 + 二分)
- Dome of Circus - UVa 1473 几何 凸包
- uva 1473 - Dome of Circus
- 【三分】HDU3756 Dome of Circus
- Dome of Circus(三分)
- UVa 1473 Dome of Circus(求凸包)
- hdu3756 Dome of Circus:三分学习
- HDU 3756 Dome of Circus 三分
- hdoj 3756 Dome of Circus(三分)
- hdu 3756 三分 Dome of Circus
- hdu 3756 Dome of Circus 三分
- hdu 3756 Dome of Circus 三分
- HDU 3756 Dome of Circus 三分
- HDU 3756 Dome of Circus (三分)
- 圆锥:转为平面几何 UVA 1473 Dome of Circus
- LA 4986 hdu3756 Dome of Circus 三分答案
- 蓝桥杯练习题 最小方差生成树 (Kruskal MST 好题)
- System.currentTimeMillis()和SystemClock.uptimeMillis()
- 老程序员的忠告:不要做浮躁的软件工程师
- MyEclipse6.5安装SVN插件方法步骤
- OAuth工作原理随想——让你的系统提供的服务更加安全(二)
- UVA 1473 - Dome of Circus(三分+计算几何)
- 字符串的排序
- 谁调用了InvocationHandler 中的invoke方法?
- 最长回文子串
- R语言数据分析系列之一
- geohash地理编码
- static_cast, dynamic_cast, reinterpret_cast, const_cast区别比较
- STL系列(5):vector 删除重复元素
- ADF中使用Sequence