hdu 5017 Ellipsoid(三分)
2014-09-15 19:41
337 查看
题目链接:hdu 5017 Ellipsoid
题目大意:给定一个面的方程,问在面上距离原点的最小值。
解题思路:三分套三分,先三分x,对于每个x,三分y,求出的最优解作为当前x的值。
题目大意:给定一个面的方程,问在面上距离原点的最小值。
解题思路:三分套三分,先三分x,对于每个x,三分y,求出的最优解作为当前x的值。
#include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; const double INF = 10000; const double eps = 1e-9; double a, b, c, d, e, f; double get(double A, double B, double C) { if (B * B - 4 * A * C < eps) return INF; return (sqrt(B * B - 4 * A * C) - B) / (2 * A); } double func (double x, double y) { double z = get(c, e * x + d * y, a * x * x + b * y * y + f * x * y - 1); return x * x + y * y + z * z; } double search (double x) { double l = -INF, r = INF; for (int i = 0; i < 200; i++) { double ll = l + (r - l) / 3; double rr = r - (r - l) / 3; if (func(x, ll) > func(x, rr)) l = ll; else r = rr; } return func(x, l); } double solve (double l, double r) { for (int i = 0; i < 200; i++) { double ll = l + (r - l) / 3; double rr = r - (r - l) / 3; if (search(ll) > search(rr)) l = ll; else r = rr; } return sqrt(search(l)); } int main () { while (scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f) == 6) { printf("%.5lf\n", solve(-INF, INF)); } return 0; }
相关文章推荐
- HDU - 5017 Ellipsoid(模拟退火法)
- HDU 5017 Ellipsoid(模拟退火)
- HDU 5017 Ellipsoid(西安网络赛K题)
- hdu 5017 Ellipsoid(模拟退火)
- hdu 5017 Ellipsoid(西安网络赛 1011)
- HDU 5017 Ellipsoid(模拟退火算法)
- HDU - 5017 Ellipsoid(模拟退火法)
- HDU 5017 Ellipsoid(退火模拟)
- hdu 5017 Ellipsoid(模拟退火)
- hdu 5017 Ellipsoid(模拟退火)
- hdu 5017 模拟退火/三分求椭圆上离圆心最近的点的距离
- hdu 5017 模拟退火/三分求椭圆上离圆心最近的点的距离
- HDU 5017 Ellipsoid(模拟退火)
- hdu 5017 Ellipsoid 模拟退火||三分
- hdu 5017 Ellipsoid(西安网络赛 1011)
- 【三分求极值】hdu 3714
- hdu 4355 Party All the Time (三分)
- hdu 4717 The Moving Points(三分)
- HDU 2438 Turn the corner(三分查找)
- The Moving Points HDU - 4717 (三分查找)