题意

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. Linux Centos关机命令

    centos关机命令: 1.halt 立马关机 2.shutdown -h 10 1分钟后自动关机 3.poweroff 立刻关机,并且电源也会断掉 4.shutdown -h now 立刻关机(ro ...

  2. 阿里云服务器上安装mysql的详细步骤

    阿里云安装mysql (1)下载mysql安装包,去mysql官网下载对应的包 mysql数据库官方下载网址:   https://downloads.mysql.com/archives/commu ...

  3. 查看json数据更新情况

    #! python3 # -*- coding:utf8 -*- #主要为读取excel中接口地址,打开网页爬取url页面中数据,解析json,检查是否符合逻辑(正常) import requests ...

  4. 关于这次安装Oracle

    前后大概经历了一个星期,今天下午(先是用的Navicat)当我尝试性的把用户名上方的复选项从服务名换成SID时,竟然瞬间连接成功了,整个人都是蒙B的,这样就好了? 之后我又用PLsql测试了一下,秒进 ...

  5. java.lang.ClassCastException: android.os.BinderProxy cannot be cast to com.test.Test

    由于我在第二个Activity中指定了进程名字,但是服务却没有指定进程名(默认跟主入口一个进程)所以报错. 网上找到的是 服务 和绑定服务的客户端必须在同一个application或者进程中,所以Ma ...

  6. activemq 生产消费模式,订阅发布模式不同类型数据传输

    1.项目结构 2. activemq-pom pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns ...

  7. system的消息队列实例

    1\创建或打开消息队列函数原型:int msgget(key_t key, int msgflg)参数第一个参数为ftok方法创建的一个kety_t或者为一个整数值第二个参数为逻辑控制,IPC_CRE ...

  8. SharePoint Framework 企业向导(四)

    博客地址:http://blog.csdn.net/FoxDave 接上一讲 嵌入JavaScript脚本 开发者常常使用的比较受欢迎的开发方式是嵌入JavaScript脚本,也叫JavaScri ...

  9. AbstractBootstrap.bind()

    ------------------headContext也就是pipeline最开头的那个handlercontext中的bind方法@Override public void bind( Chan ...

  10. Gym - 100989M(dp)

    George met AbdelKader in the corridor of the CS department busy trying to fix a group of incorrect e ...