LA 5009 三分
来源:互联网 发布:linux stopped 编辑:程序博客网 时间:2024/05/26 20:19
#include <cstdio>#include <algorithm>using namespace std;const int maxn = 10000 + 10;int n, a[maxn], b[maxn], c[maxn];double F(double x){double ans = a[0] * x * x + b[0] * x + c[0];for (int i = 1; i < n; i++)ans = max(ans, a[i] * x * x + b[i] * x + c[i]);return ans;}int main(int argc, char const *argv[]){int T;scanf("%d", &T);while (T--){scanf("%d", &n);for (int i = 0; i < n; i++)scanf("%d%d%d", a + i, b + i, c + i);double L = 0.0, R = 1000.0;for (int i = 0; i < 100; i++){double m1 = L + (R - L) / 3;double m2 = R - (R - L) / 3;if (F(m1) < F(m2)) R = m2;else L = m1;}printf("%.4lf\n", F(L));}return 0;}
单峰函数使用三分来求值
0 0
- LA 5009 三分
- la 5009 - Error Curves(三分)
- LA 4986 三分
- LA 5009 (HDU 3714) Error Curves (三分)
- LA 4986 hdu3756 Dome of Circus 三分答案
- LA 5009
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- BZOJ_P1072 [SCOI2007]排列perm(状态压缩动态规划)
- sass继承 %占位符placeholder
- ubuntu15.10 配置tftp
- find命令中参数perm的用法
- UVa--437 The Tower of Babylon(dp)
- LA 5009 三分
- MFC中,编译器无法识别类等问题的另一种情况。
- 容器的allocator(容器配置器)(一)
- sass(混合宏vs继承vs占位符)
- POJ 2989 All Friends (极大团数量 + 全局变量局部变量)
- sass笔记之开始
- mysql 5.5中的半同步复制
- 新生项目总结之---组织管理与文档的书写
- 容器配置器(allocator)(二)