设为首页 加入收藏

TOP

hdu 5017 Ellipsoid(模拟退火)
2015-07-20 17:34:17 来源: 作者: 【 】 浏览:2
Tags:hdu 5017 Ellipsoid 模拟

Ellipsoid

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1140 Accepted Submission(s): 412
Special Judge


Problem Description Given a 3-dimension ellipsoid(椭球面)
\

your task is to find the minimal distance between the original point (0,0,0) and points on the ellipsoid. The distance between two points (x 1,y 1<??http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vc3ViPix6PHN1Yj4xPC9zdWI+KSBhbmQgKHg8c3ViPjI8L3N1Yj4seTxzdWI+Mjwvc3ViPix6PHN1Yj4yPC9zdWI+KSBpcyBkZWZpbmVkIGFzIDxpbWcgc3JjPQ=="https://www.cppentry.com/upload_files/article/49/1_xdafq__.jpg" alt="\">
Input There are multiple test cases. Please process till EOF.

For each testcase, one line contains 6 real number a,b,c(0 < a,b,c,< 1),d,e,f(0 ≤ d,e,f < 1), as described above. It is guaranteed that the input data forms a ellipsoid. All numbers are fit in double.

Output For each test contains one line. Describes the minimal distance. Answer will be considered as correct if their absolute error is less than 10-5.
Sample Input
1 0.04 0.01 0 0 0

Sample Output
1.0000000

Source 2014 ACM/ICPC Asia Regional Xi'an Online
题解: 这题也是看了看别人的题解,学习了一下模拟退火,感觉不难,挺简单。整体的思路就是8个方向的搜索,退火的意思就是逐渐缩小搜索范围,从而使最后的解足够精确。
#include 
   
    
#include 
    
      #include 
     
       #include 
      
        using namespace std; const double sp=0.99,eps=1e-8; double a,b,c,d,e,f,M=1e9; double dirx[]={-1,-1,-1,0,0,1,1,1}; double diry[]={-1,0,1,-1,1,-1,0,1}; double dis(double x,double y,double z) { return sqrt(x*x+y*y+z*z); } double getz(double x,double y) { double A=0,B=0,C=0; A=c; B=d*y+e*x; C=a*x*x+b*y*y+f*x*y-1; double delta=B*B-4*A*C; if(delta<0) return M; double z1=(sqrt(delta)-B)/(2.0*A),z2=(-sqrt(delta)-B)/(2.0*A); if(z1*z1
       
        eps) { for(int i=0;i<8;i++) { tx=x+dirx[i]*step; ty=y+diry[i]*step; tz=getz(tx,ty); if(tz>=M) continue; if(dis(tx,ty,tz)
        
         





】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇BZOJ 1878 SDOI 2009 HH的项链 树.. 下一篇Largest Rectangular Area in a H..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·在 Redis 中如何查看 (2025-12-26 03:19:03)
·Redis在实际应用中, (2025-12-26 03:19:01)
·Redis配置中`require (2025-12-26 03:18:58)
·Asus Armoury Crate (2025-12-26 02:52:33)
·WindowsFX (LinuxFX) (2025-12-26 02:52:30)