博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 5017 Ellipsoid(西安网络赛 1011)
阅读量:4334 次
发布时间:2019-06-07

本文共 1868 字,大约阅读时间需要 6 分钟。

Ellipsoid

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 850    Accepted Submission(s): 271
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,z
1) and (x
2,y
2,z
2) is defined as 
 

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
 

第一次了解模拟退火。

求z时已知x,y转化为关于z的二次方程,用韦达定理求z。

关于退火速度,測了一下,r=0.99时是281ms,r=0.98时是140ms,r=0.97时是93ms,r=0.96时就wa了。

代码:、

//97ms#include 
#include
#include
#include
#include
using namespace std;const int dx[8]={0,0,1,-1,1,-1,1,-1};const int dy[8]={1,-1,0,0,-1,1,1,-1};const double r=0.97;const double eps=1e-8;double a,b,c,d,e,f;double dis(double x,double y,double z){ return sqrt(x*x+y*y+z*z);}double getz(double x,double y)//求z{ double A=c; double B=d*y+e*x; double C=f*x*y+a*x*x+b*y*y-1; double delta=B*B-4*A*C; if(delta<0) { return 1e30; } else { double z1=(-B+sqrt(delta))/A/2; double z2=(-B-sqrt(delta))/A/2; return z1*z1
eps) { z=getz(x,y); for(int i=0;i<8;i++) { double xi=x+dx[i]*step; double yi=y+dy[i]*step; double zi=getz(xi,yi); if(zi>1e20) continue; if(dis(xi,yi,zi)

转载于:https://www.cnblogs.com/hrhguanli/p/4021104.html

你可能感兴趣的文章
UIView的layoutSubviews,initWithFrame,initWithCoder方法
查看>>
STM32+IAP方案 实现网络升级应用固件
查看>>
用74HC165读8个按键状态
查看>>
jpg转bmp(使用libjpeg)
查看>>
linear-gradient常用实现效果
查看>>
sql语言的一大类 DML 数据的操纵语言
查看>>
VMware黑屏解决方法
查看>>
JS中各种跳转解析
查看>>
JAVA 基础 / 第八课:面向对象 / JAVA类的方法与实例方法
查看>>
Ecust OJ
查看>>
P3384 【模板】树链剖分
查看>>
Thrift源码分析(二)-- 协议和编解码
查看>>
考勤系统之计算工作小时数
查看>>
4.1 分解条件式
查看>>
Equivalent Strings
查看>>
flume handler
查看>>
收藏其他博客园主写的代码,学习加自用。先表示感谢!!!
查看>>
H5 表单标签
查看>>
su 与 su - 区别
查看>>
C语言编程-9_4 字符统计
查看>>