Uva5009 Error Curves
已知n条二次曲线si(x) = ai*x^2 + bi*x + ci(ai ≥ 0),定义F(x) = max{si(x)},求出F(x)在[0,1000]上的最小值.
链接:传送门
分析:最大值最小,我们可以利用二分来解,但是有一个更牛的方法叫:“三分法”,这个方法的应用范围是凸函数,可以看一个图像:
L和R是边界,m1,m2是三等分点,如果f(m1) < f(m2),那么最小值肯定在[l,m2]内,注意,不是[l,m1]因为如果m1在最低点右边,那么就会矛盾,同理,如果f(m2) < f(m1),那么最小值肯定在[m1,r]之间,剩下的操作和二分法基本上就是一样的了。
对于本题而言,可以看出也是一个凸函数,所以我们可以利用三分法来快速求最小值.
#include<iostream> #include<cstdio> #include<cstring> #include<queue> #include<cmath> #include<map> #include<string>using namespace std;const int maxn = 10010;int n, a[maxn], b[maxn], c[maxn],t;double f(double x) {double ans = a[1] * x * x + b[1] * x + c[1];for (int i = 2; i <= n; i++)ans = max(ans, a[i] * x*x + b[i] * x + c[i]);return ans; }int main() {scanf("%d", &t);while (t--){scanf("%d", &n);for (int i = 1; i <= n; i++)scanf("%d%d%d", &a[i], &b[i], &c[i]);double L = 0.0, R = 1000.0;while (R - L > 0.000000001){double m1 = L + (R - L) / 3, m2 = R - (R - L) / 3;if (f(m1) < f(m2))R = m2;elseL = m1;}printf("%.4lf\n", f(L));}return 0; }
转载于:https://www.cnblogs.com/zbtrs/p/7413234.html
Uva5009 Error Curves相关推荐
- 【HDU - 3714 】Error Curves (三分)
题干: Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention t ...
- uva 1476 - Error Curves
对x的坐标三分: 1 #include<cstdio> 2 #include<algorithm> 3 #define maxn 10009 4 using namespace ...
- 《算法入门经典大赛——培训指南》第二章考试
UVa特别考试 UVa站点专门为本书设立的分类题库配合,方便读者提交: http://uva.onlinejudge.org/index.php?option=com_onlinejudge& ...
- Paper:Xavier参数初始化之《Understanding the difficulty of training deep feedforward neural networks》的翻译与解读
Paper:Xavier参数初始化之<Understanding the difficulty of training deep feedforward neural networks>的 ...
- Paper:《How far are we from solving the 2D 3D Face Alignment problem? 》解读与翻译
Paper:<How far are we from solving the 2D & 3D Face Alignment problem? >解读与翻译 目录 How far a ...
- Paper之DL之BP:《Understanding the difficulty of training deep feedforward neural networks》
Paper之DL之BP:<Understanding the difficulty of training deep feedforward neural networks> 目录 原文解 ...
- xavier初始化_深入解读xavier初始化(附源码)
论文是Understanding the difficulty of training deep feedforward neural networks. 一篇感觉不错的翻译为[Deep Learni ...
- 经典DL论文研读(part1)--Understanding the difficulty of training deep feedforward neural networks
学习笔记,仅供参考,有错必纠 文章目录 Understanding the difficulty of training deep feedforward neural networks Abstra ...
- 统计学习导论_统计学习导论 | 读书笔记11 | 多项式回归和阶梯函数
ISLR(7)- 非线性回归分析 多项式回归和阶梯函数 Note Summary: 0.从理想的线性到现实的非线性 1.多项式回归 2.Step Function 3.参考 0. Moving Bey ...
最新文章
- Cocos Creator 的 动作(Action)系统:moveBy的使用
- FPGA设计中MEMORY型数据怎么综合到blockRAM里面
- bootstrap table 分组_bootstrap-table组合表头的实现方法
- 啥是指标陷阱?很多就出现在你的身边!
- Merge和Rebase在Git中的区别
- AIX卷管理介绍以及利用空闲PP来创建文件系统
- matlab slovenia,QUAD-MxFE Platform
- 计算机风格学,由风格学习算法自动生成大规模手写字体
- oracle按位或运算符怎么用,Oracle按位运算符
- 动态创建表格(各种管理系统常见)
- 《Entity Framework 6 Recipes》中文翻译系列 (42) ------ 第八章 POCO之使用POCO
- Flash竖向大焦点图代码_网页代码站(www.webdm.cn)
- Word排版艺术—读书笔记
- 火狐中国区linux无法同步,教大家火狐浏览器同步数据失败的几点原因
- 2021年N1叉车司机找解析及N1叉车司机考试试卷
- 游戏官网的HTML布局,游戏网站页面布局关键
- CRF++安装教程(含Windows和Linux两个版本)
- srand(time(0))函数的用法介绍
- GRO checksum在tcpdump中incorrect的问题
- 一些优秀的后端开源项目!