题意

PDF

分析

因为这些函数都可以看成下凸的,所以总函数也是下凸的(可用反证法证明)。

三分答案即可,时间复杂度\(O(100)\)

代码

#include<bits/stdc++.h>
#define rg register
#define il inline
#define co const
template<class T>il T read(){
    rg T data=0,w=1;rg char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-') w=-1;ch=getchar();}
    while(isdigit(ch)) data=data*10+ch-'0',ch=getchar();
    return data*w;
}
template<class T>il T read(rg T&x) {return x=read<T>();}
typedef long long ll;

co int N=1e4;
int n,a[N],b[N],c[N];
double F(double x){
    double ans=a[0]*x*x+b[0]*x+c[0];
    for(int i=1;i<n;++i) ans=std::max(ans,a[i]*x*x+b[i]*x+c[i]);
    return ans;
}
int main(){
//  freopen(".in","r",stdin),freopen(".out","w",stdout);
    for(int T=read<int>();T--;){
        read(n);
        for(int i=0;i<n;++i) read(a[i]),read(b[i]),read(c[i]);
        double L=0,R=1000;
        for(int i=0;i<100;++i){
            double m1=L+(R-L)/3,m2=R-(R-L)/3;
            F(m1)<F(m2)?R=m2:L=m1;
        }
        printf("%.4lf\n",F(L));
    }
    return 0;
}

LA5009 Error Curves的更多相关文章

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

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

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

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

  3. Error Curves HDU - 3714

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

  4. UVA 5009 Error Curves

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

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

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

  6. hdu 3714 Error Curves(三分)

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

  7. HDU 3714/UVA1476 Error Curves

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

  8. 三分 HDOJ 3714 Error Curves

    题目传送门 /* 三分:凹(凸)函数求极值 */ #include <cstdio> #include <algorithm> #include <cstring> ...

  9. UVA 1476 - Error Curves(三分法)

    UVA 1476 1476 - Error Curves 题目链接 题意:给几条下凹二次函数曲线.然后问[0,1000]全部位置中,每一个位置的值为曲线中最大值的值,问全部位置的最小值是多少 思路:三 ...

随机推荐

  1. java-Object类的解析(持续更新)

    1.getClass()方法 public class Object { /*一个本地方法,具体是用C(C++)在DLL中实现的,然后通过JNI调用*/ private static native v ...

  2. 【收集资料】OpenGL学习

    1.课本配套网站,有Sample Code和书中的图片等   http://math.ucsd.edu/~sbuss/MathCG/ 2.Visual C++的帮助系统可查阅基本OpenGL函数(不包 ...

  3. linux生成SSH key

    1. 检查SSH keys是否存在 ls -al ~/.ssh2. 生成新的ssh key 输入 ssh-keygen -t rsa -C your_email@example.com

  4. 首次编译Java小程序

    public class helloworld { public static void main(string[] args) { system.out.println("hello wo ...

  5. 牛客多校第五场 F take

    链接:https://www.nowcoder.com/acm/contest/143/F来源:牛客网 题目描述 Kanade has n boxes , the i-th box has p[i] ...

  6. Day4作业及默写

    1,写代码,有如下列表,按照要求实现每一个功能 li = ["alex", "WuSir", "ritian", "barry&q ...

  7. Kaggle(2):验证和过分拟合

    目前看来,随机森林是比较常用且有效的分类算法.以下先简要介绍python中随机森林的使用方法,然后谈谈分类结果的准确度验证和过拟合等两个重要问题. 1.随机森林的参数 在Scikit learn中使用 ...

  8. Collection集合复习方法回顾

    Collection集合方法: add()  //添加元素 remove()    //移除元素 size()                                     //返回集合长度 ...

  9. Python 时间

    import time # 时间戳: 从1970-01-01 00:00:00开始计算. 未来存储的时候用是时间戳 print(time.time()) # 格式化时间 print(time.strf ...

  10. 【git学习笔记】

    一.查看git的配置文件 1.在项目下,有一个.git的隐藏文件 2.config为git的配置文件 3.查看config :branch表示分支,此配置文件表示当前有两个分支NNU和master,一 ...