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