G - Dome of Circus UVALive - 4986 (三分)
2017-08-06 18:28
459 查看
https://vjudge.net/contest/123097#problem/G
三分最后一题
其实看上去像一个三维问题,分分钟化成二维平面内的问题, 三分的是体积,我们只要比较r*r*h的大小就行,
下凸函数,自己画一下图感受一下就行了. 还是用斜率的角度走一下流程.
三分最后一题
其实看上去像一个三维问题,分分钟化成二维平面内的问题, 三分的是体积,我们只要比较r*r*h的大小就行,
下凸函数,自己画一下图感受一下就行了. 还是用斜率的角度走一下流程.
#include<cstdio> #include<iostream> #include<cmath> const int maxn = 1e4+5; const double eps = 1e-9; const double PI = acos(-1.0); using namespace std; int n; double ansr, ansh; struct Point{ double x,y; Point(){} Point(double x, double y):x(x),y(y){} }p[maxn]; double cal(double ang){ double maxv = 0; double a,b; for(int i = 0; i < n; i++){ b = p[i].x*tan(ang) + p[i].y; a = b/tan(ang); maxv = max(maxv, a*a*b); } return maxv; } int main(){ double xx,yy,zz; while(~scanf("%d",&n) && n){ for(int i = 0; i < n; i++){ scanf("%lf%lf%lf",&xx,&yy,&zz); p[i].x = eps+sqrt(xx*xx+yy*yy); p[i].y = zz; } double l = 0, r = PI/2, mid1, mid2; for(int i = 0; i < 100; i++){ mid1 = l + (r - l)/3; mid2 = r - (r - l)/3; if(cal(mid1) < cal(mid2)) r = mid2; else l = mid1; } double v = cal(l); ansr = pow(v/tan(l),(double)(1.0/3)); ansh = tan(l)*ansr; printf("%.3lf %.3lf\n",ansh,ansr); } return 0; }
相关文章推荐
- UVALive 4986 Dome of Circus(三分、凸包、凸性函数)
- UVA 1473&LA 4986 - Dome of Circus
- UVA 1473 - Dome of Circus(三分+计算几何)
- UVa 1473 - Dome of Circus 三分
- uvalive 4986(三分查找)
- UVALive 7509 三分
- UVALive 7509 三分
- UVALive 7509 三分
- Dome of Circus(三分)
- ACM--steps--4.1.7--Dome of Circus(三分)
- hdoj 3756 Dome of Circus(三分)
- UVALive 6694 Toy Boxes (枚举 + 三分)
- UVALive 7509 三分
- 【三分】HDU3756 Dome of Circus
- UVALive 7509 三分
- HDU 3756 Dome of Circus 三分
- HDU 3756 Dome of Circus (三分)
- uva 1473 - Dome of Circus (几何 + 二分)
- UVALive 7509 三分
- E - Euclidean TSP UVALive - 6954 (三分)