Ellipsoid HDU - 5017(模拟退火)
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
第一個(gè)模擬退火的題目。其實(shí)模擬退火就根蒙特卡洛算法差不多,根據(jù)概率大小去找尋有可能得最優(yōu)解。模擬退火通常來(lái)解決計(jì)算幾何找解的問(wèn)題。
這個(gè)題是找原點(diǎn)到一個(gè)橢圓體表面的最近的位置。我們每一個(gè)點(diǎn)都有八個(gè)方向去拓展,但是一開始的點(diǎn)概率大一些,這就是模擬退火的部分。我們枚舉x,y去計(jì)算z。不斷的記錄下最優(yōu)值。
代碼如下:
努力加油a啊,(o)/~
總結(jié)
以上是生活随笔為你收集整理的Ellipsoid HDU - 5017(模拟退火)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 233 Matrix HDU - 501
- 下一篇: 模拟退火总结+洛谷模板题(P1337 [