LA5009——三分求极小值
来源:互联网 发布:mysql 查看表的索引 编辑:程序博客网 时间:2024/05/29 04:45
题意:给出n个二次曲线Si(x),求函数F(x) = max{Si(x)}在区间[0, 1000]上的极小值。
由于给出的二次曲线都是开口向上的,可以看出F(x)也是凸性函数,赤裸裸的三分啊。
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>using namespace std;template<class T> inline void checkmax(T & x, T y) { if(y > x) x = y; }template<class T> inline void checkmin(T & x, T y) { if(y < x) x = y; }const int maxn = 10000 + 10;int a[maxn], b[maxn], c[maxn], n;double f(double x){ double res = a[0] * x * x + b[0] * x + c[0]; for(int i = 1; i < n; ++i) checkmax(res, a[i] * x * x + b[i] * x + c[i]); return res;}int main(){ freopen("in.txt", "r", stdin); 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, r = 1000; while(r - l > 1e-13) { double mid = (r + l) / 2; double mmid = (r + mid) / 2; if(f(mid) - f(mmid) < 1e-10) r = mmid; else l = mid; } printf("%.4lf\n", f(l)); } return 0;}/*212 0 022 0 02 -4 20.00000.5000*/
- LA5009——三分求极小值
- LA5009三分
- LA5009 Error Curves(三分)
- 【算法分析】之重新认识三分-----求极值(极大值和极小值)
- 区域极小值—lhMorpRMin
- H极小值—lhMorpHMin
- 扩展极小值—lhMorpEMin
- 求极大和极小值
- 三分求最小值——HDU3400
- 三分求最小值——HDU 2241
- Locating a minimum 求极小值
- 牛顿法求极大极小值
- 梯度下降法求极小值
- UVA1476——Error Curves (三分求极值)
- ZOJ 3203 Light Bulb——(三分求极值)
- 最优控制理论总结——极小值原理PMP
- 漫步数学分析三十七——极大值与极小值
- Newton迭代法求函数极小值点 Matlab程序
- Codeforces 284A Cows and Primitive Roots [模拟题]
- ubuntu12.10安装QQ2012
- C# 用GDI在图片上写字实现lable透明背景
- 时序图,协作图,状态图,活动图,对象图 简介
- ORA-01035: ORACLE only available to users with RESTRICTED SESSION privilege
- LA5009——三分求极小值
- MFC对话框程序最大化时控件相应变化
- C++学习笔记-构造函数的理解
- Android 去掉titlebar的最优解决方案
- 基于 Android NDK 的学习之旅-----Android.mk 介绍
- 透过一些实例理解数组和指针的一些细节
- 产品经理类产品的探索之路
- 兴趣杂谈
- 关注正则表达中贪婪匹配的说明