大意:
给你n个二次函数Si(x),F(x) = max{Si(x)}
求F(x)在[0,1000]上的最小值。
S(x)=ax^2+bx+c

      (0<=a<=100, |b|,|c|<=5000)


简单分析一下可知函数F(x)的图形是下凸函数,可以采用三分法求最值。


CODE:

#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 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;
}

求单峰函数的极值也可以用黄金分割法



HDU3714 Error Curves (单峰函数)的更多相关文章

  1. HDU-3714 Error Curves(凸函数求极值)

    Error Curves Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

  2. hdu3714 Error Curves

    题目: Error Curves Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  3. 【单峰函数,三分搜索算法(Ternary_Search)】UVa 1476 - Error Curves

    Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a m ...

  4. Error Curves(2010成都现场赛题)

    F - Error Curves Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Descript ...

  5. Error Curves HDU - 3714

    Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a m ...

  6. UVA 5009 Error Curves

    Problem Description Josephina is a clever girl and addicted to Machine Learning recently. She pays m ...

  7. LA 5009 (HDU 3714) Error Curves (三分)

    Error Curves Time Limit:3000MS    Memory Limit:0KB    64bit IO Format:%lld & %llu SubmitStatusPr ...

  8. hdu 3714 Error Curves(三分)

    Error Curves Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Tot ...

  9. HDU 3714/UVA1476 Error Curves

    Error Curves Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

随机推荐

  1. Android 电话自己主动接听和挂断具体解释

    1.通过aidl及反射实现挂断电话 详细分三步: (1)ITelephony.aidl ,必须新建com.android.internal.telephony包并放入ITelephony.aidl文件 ...

  2. UItableViewCell上的button点击无响应的办法

    由于IOS7中添加了滑动后出现编辑按钮的操作,所以使用scrollView来处理,UITableViewCellScrollView有对触摸的相应处理,导致按钮的点击效果被屏蔽了,但是点击事件还是在的 ...

  3. 网页制作之html基础学习6-CSS浏览器兼容问题

    初学html和css时,每天切图,总会遇到很多浏览器兼容性问题.最近一直关注移动平台开发,就html和css来说,不用考虑那么多浏览器兼容性问题.到现在,以至于很多浏览器兼容性几乎忘光了.今天把以前总 ...

  4. java设计模式之——策略模式

    1.策略模式有什么好处? 策略模式的好处在于你可以动态的改变对象的行为. 2.设计原则 设计原则是把一个类中经常改变或者将来可能改变的部分提取出来,作为一个接口(c++中可以用虚类),然后在类中包含这 ...

  5. 运行复制的ZooKeeper 部署

    运行复制的ZooKeeper 运行ZooKeeper 在一个独立模式下是方便评估的, 一些开发,和测试. 但是在生产,你应该运行ZooKeeper 在复制模式.一个复制的servers group 在 ...

  6. Js脚本实现选项卡的实例

    效果演示: 具体代码: <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http:/ ...

  7. Regionals 2012, North America - Greater NY 解题报告

    这套题..除了几何的都出了 完全没时间学几何.杯具 A,B,J 水题不解释 C.Pen Counts 这题的话 写几个不等式限制边得范围就行了 然后枚举最小边 D.Maximum Random Wal ...

  8. Login oracle for external authenticate

    Generally, we can login the oracle by os authentication, if we login os in a remote machine and make ...

  9. [置顶] Objective-C ,ios,iphone开发基础:UIAlertView使用详解

    UIAlertView使用详解 Ios中为我们提供了一个用来弹出提示框的类 UIAlertView,他类似于javascript中的alert 和c#中的MessageBox(); UIAlertVi ...

  10. 【BOI2007】【BZOJ1176】Mokia

    1176: [Balkan2007]Mokia Time Limit: 30 Sec Memory Limit: 162 MB Submit: 1059 Solved: 432 [Submit][St ...