已知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相关推荐

  1. 【HDU - 3714 】Error Curves (三分)

    题干: Josephina is a clever girl and addicted to Machine Learning recently. She  pays much attention t ...

  2. uva 1476 - Error Curves

    对x的坐标三分: 1 #include<cstdio> 2 #include<algorithm> 3 #define maxn 10009 4 using namespace ...

  3. 《算法入门经典大赛——培训指南》第二章考试

    UVa特别考试 UVa站点专门为本书设立的分类题库配合,方便读者提交: http://uva.onlinejudge.org/index.php?option=com_onlinejudge& ...

  4. Paper:Xavier参数初始化之《Understanding the difficulty of training deep feedforward neural networks》的翻译与解读

    Paper:Xavier参数初始化之<Understanding the difficulty of training deep feedforward neural networks>的 ...

  5. 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 ...

  6. Paper之DL之BP:《Understanding the difficulty of training deep feedforward neural networks》

    Paper之DL之BP:<Understanding the difficulty of training deep feedforward neural networks> 目录 原文解 ...

  7. xavier初始化_深入解读xavier初始化(附源码)

    论文是Understanding the difficulty of training deep feedforward neural networks. 一篇感觉不错的翻译为[Deep Learni ...

  8. 经典DL论文研读(part1)--Understanding the difficulty of training deep feedforward neural networks

    学习笔记,仅供参考,有错必纠 文章目录 Understanding the difficulty of training deep feedforward neural networks Abstra ...

  9. 统计学习导论_统计学习导论 | 读书笔记11 | 多项式回归和阶梯函数

    ISLR(7)- 非线性回归分析 多项式回归和阶梯函数 Note Summary: 0.从理想的线性到现实的非线性 1.多项式回归 2.Step Function 3.参考 0. Moving Bey ...

最新文章

  1. Cocos Creator 的 动作(Action)系统:moveBy的使用
  2. FPGA设计中MEMORY型数据怎么综合到blockRAM里面
  3. bootstrap table 分组_bootstrap-table组合表头的实现方法
  4. 啥是指标陷阱?很多就出现在你的身边!
  5. Merge和Rebase在Git中的区别
  6. AIX卷管理介绍以及利用空闲PP来创建文件系统
  7. matlab slovenia,QUAD-MxFE Platform
  8. 计算机风格学,由风格学习算法自动生成大规模手写字体
  9. oracle按位或运算符怎么用,Oracle按位运算符
  10. 动态创建表格(各种管理系统常见)
  11. 《Entity Framework 6 Recipes》中文翻译系列 (42) ------ 第八章 POCO之使用POCO
  12. Flash竖向大焦点图代码_网页代码站(www.webdm.cn)
  13. Word排版艺术—读书笔记
  14. 火狐中国区linux无法同步,教大家火狐浏览器同步数据失败的几点原因
  15. 2021年N1叉车司机找解析及N1叉车司机考试试卷
  16. 游戏官网的HTML布局,游戏网站页面布局关键
  17. CRF++安装教程(含Windows和Linux两个版本)
  18. srand(time(0))函数的用法介绍
  19. GRO checksum在tcpdump中incorrect的问题
  20. 一些优秀的后端开源项目!

热门文章

  1. JavaScript 获取服务器端checkBoxlist控件选中的值
  2. operate XML file (Open,Insert)
  3. 行人检测 读书笔记 综述
  4. 石头剪刀布 手势识别
  5. 商品搜索引擎---推荐系统设计
  6. 残差学习,152层网络,微软夺冠2015 ImageNet计算机视觉识别挑战
  7. SAD立体匹配算法在opencv中的实现
  8. MySQL中删除重复数据
  9. 超高性能管线式HTTP请求(实践·原理·实现)
  10. 微软Hololens设备 浅分析