HDU 5017 Ellipsoid(西安网络赛K题)
来源:互联网 发布:人工智能技术与生活 编辑:程序博客网 时间:2024/05/12 13:09
HDU 5017 Ellipsoid
题目链接
思路:模拟退火大法好!
代码:
#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const int D[8][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {-1, -1}, {1, -1}, {-1, 1}};double a, b, c, d, e, f;const double INF = 1e9;const double eps = 1e-8;double dis(double x, double y, double z) {return sqrt(x * x + y * y + z * z);}double cal(double x, double y) {double A = c;double B = d * y + e * x;double C = f * x * y + a * x * x + b * y * y - 1;double del = B * B - 4 * A * C;if (del < 0) return 1e10;del = sqrt(del);double z1 = (-B + del) / A / 2;double z2 = (-B - del) / A / 2;if (dis(x, y, z1) < dis(x, y, z2)) return z1;return z2;}double solve() {double x = 0, y = 0, z = sqrt(1.0 / c);double step = 1.0, r = 0.99;while (step > eps) {for (int i = 0; i < 8; i++) {double xx = x + step * D[i][0];double yy = y + step * D[i][1];double zz = cal(xx, yy);if (zz > INF) continue;if (dis(xx, yy, zz) < dis(x, y, z)) {x = xx; y = yy; z = zz;}}step *= r;}return dis(x, y, z);}int main() {while (~scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f)) {printf("%.7lf\n", solve());}return 0;}
3 3
- HDU 5017 Ellipsoid(西安网络赛K题)
- hdu 5017 Ellipsoid(西安网络赛 1011)
- hdu 5017 Ellipsoid 模拟退火算法 西安网络赛
- HDU 5008西安网络赛B题:后缀数组求第k小子串
- HDU 5017 Ellipsoid 模拟退火第一题
- HDU 5017 Ellipsoid(退火模拟)
- HDU 5017 Ellipsoid(模拟退火算法)
- hdu 5017 Ellipsoid(模拟退火)
- HDU 5017 Ellipsoid(模拟退火)
- hdu 5017 Ellipsoid(模拟退火)
- [HDU 5017] Ellipsoid (模拟退火)
- HDU 5017 Ellipsoid
- hdu 5017 Ellipsoid(三分)
- HDU 5017 Ellipsoid
- hdu 5017 Ellipsoid
- hdu 5017 Ellipsoid
- HDU 5007 Post Robot(西安网络赛A题)
- HDU 5009 Paint Pearls(西安网络赛C题)
- NYOJ 题目1069 生活的难题(位运算,技巧)
- Servlet页面跳转实现方法的区别
- #与##宏定义的作用
- google codejam 2014年9月15日场C题题解
- Linux是怎么启动的(整理)
- HDU 5017 Ellipsoid(西安网络赛K题)
- CAML——Join多表连接查询
- MVP 模式-计算器实例
- <context-param>与<init-param>的区别与作用
- eh教你快速掌握excel格式化显示
- C#下计算字符串MD5值
- Android内存管理之道
- HDU 5008 Boring String Problem 后缀数组 RMQ
- 外部程序调用应用Activity方法简介