hdu 3756 Dome of Circus 三分
来源:互联网 发布:数据分析技术发展趋势 编辑:程序博客网 时间:2024/05/09 06:10
求 能包围 n个点的 最小体积的圆锥 的 高 和 底面半径。
对于一个点而言,通过分析 体积公式。 求导后,公式是单点的。 所以 体积公式是 先下降 后上升 (推导和分析好一会)。
而对于n个点, Fi (h) 为高为h 时最小体积。
对于 高 h,得到 最小 V = max( Fi (h)) i 为 1--n
分析的 n 个 对钩函数 的max 也是对钩函数 (这里对钩函数是 先下降 在上升的函数即可)。
因此对于n个点的最小包围圆锥 的体积 对于 高h 而言就是 一个 先下降在上升。 这样就可以三分。
#include <vector>#include <list>#include <map>#include <set>#include <deque>#include <stack>#include <cstring>#include <bitset>#include <algorithm>#include <functional>#include <numeric>#include <utility>#include <sstream>#include <iostream>#include <iomanip>#include <cstdio>#include <cmath>#include <cstdlib>#include <ctime>#include <assert.h>#include <queue>#define REP(i,n) for(int i=0;i<n;i++)#define TR(i,x) for(typeof(x.begin()) i=x.begin();i!=x.end();i++)#define ALLL(x) x.begin(),x.end()#define SORT(x) sort(ALLL(x))#define CLEAR(x) memset(x,0,sizeof(x))#define FILLL(x,c) memset(x,c,sizeof(x))using namespace std;const double eps = 1e-9;#define LL long long #define pb push_backconst int maxn = 10100;const double PI = 3.1415926;double x[maxn],y[maxn],z[maxn];int n ;double f(double a){ double ret = 0; for(int i=1;i<=n;i++){ double l = sqrt(x[i]*x[i]+y[i]*y[i]); double h = z[i]; double r = h*l/(a-h)+l; // cout << l << " "<< h<< " "<<r <<endl; ret = max(ret , r); } return ret;}double s(double a){ double r = f(a); // cout << a << " "<< r<<endl; return PI*r*r *a/3;}double down = 0 ;void solve(){ //cout << f(3)<<"fasdfas"<<endl; double left = down + 1e-6; double right = 1e7; while(right - left >1e-4){ // cout << left << " "<<right <<endl; double lmid = (left + right)/2; double rmid = (lmid + right )/2; //cout << lmid << "**** "<<rmid<<endl; if(s(lmid)>s(rmid)){ left = lmid ; }else{ right = rmid; } } double h = left ; double r = f(left); printf("%.3lf %.3lf\n",h,r);}int main(){ int t ; cin >>t ; while(t--){ scanf("%d",&n); down = 0 ; for(int i=1;i<=n;i++){ scanf("%lf%lf%lf",&x[i],&y[i],&z[i]); down = max(down , z[i]); } solve(); } return 0;}
- 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 三分
- HDU 3756 Dome of Circus (三分)
- HDU 3756 Dome of Circus(计算几何 + 三分)
- hdoj 3756 Dome of Circus(三分)
- HDU 3756 Dome of Circus
- 【三分】HDU3756 Dome of Circus
- Dome of Circus(三分)
- HDU Dome of Circus
- hdu 3756 || Dome of Circus || 2010 Northeastern European Regional Contest(三分)
- hdu3756 Dome of Circus:三分学习
- hdu 3756 Dome of Circus(模拟退火)
- HDU 3756,LA 4986——Dome of Circus
- LA 4986 hdu3756 Dome of Circus 三分答案
- ACM--steps--4.1.7--Dome of Circus(三分)
- 求任意8比特数在AES的S-Box中的对应值
- ARM汇编中ldr与adr的区别(转)
- SSIS_控制流(FTP 任务)
- 使用乘法表计算GF(2^8)中的乘法
- ARM汇编中的LDR及ADR的区别及其在U-BOOT中的应用
- hdu 3756 Dome of Circus 三分
- android学习之路--生命周期与意图
- maya
- IC芯片 科技电子 科技领域巨头动作
- SEO前端优化
- Python下科学计算包numpy和SciPy的安装
- windows下python安装Numpy和Scipy模块
- CCS架构与starterware SDK结构解析
- 【Deep Learning学习笔记】Deep learning for nlp without magic_Bengio_ppt_acl2012