画出函数图像后,发现是一个类似V字型的图。

可以用三分法找图像最低点

WA了一串,之后发现是读入优化迷之被卡。

 /*by SilverN*/
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
const int mxn=;
int a[mxn],b[mxn],c[mxn];
int n;
double f(double x){
double ans=a[]*x*x+b[]*x+c[];
for(int i=;i<=n;i++)
ans=max(ans,a[i]*x*x+b[i]*x+c[i]);
return ans;
}
int main(){
int T;
scanf("%d",&T);
int i,j;
while(T--){
scanf("%d",&n);
for(i=;i<=n;i++){
scanf("%d%d%d",&a[i],&b[i],&c[i]);
// a[i]=read();b[i]=read();c[i]=read();
// printf("%d %d %d\n",a[i],b[i],c[i]);
}
double l=,r=;
for(i=;i<=;i++){
double mid1=(l*+r)/;
double mid2=(l+r*)/;
if(f(mid1)<f(mid2))r=mid2;
else l=mid1;
}
printf("%.4f\n",f(l));
}
return ;
}

UVa1476 Error Curves的更多相关文章

  1. HDU 3714/UVA1476 Error Curves

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

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

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

  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 HDU - 3714

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

  5. UVA 5009 Error Curves

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

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

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

  7. hdu 3714 Error Curves(三分)

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

  8. 三分 HDOJ 3714 Error Curves

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

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

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

随机推荐

  1. HTML5<aside>元素

    HTML5<aside>元素用来定义页面文档中主区域内容之外的内容,但之外的内容是与主区域内容相关的. 实例: <article> <h1>这个页面是我开始用htm ...

  2. Where do I belong-freecodecamp算法题目

    Where do I belong(数组排序并找出元素索引) 要求 给数组排序 找到指定的值在数组的位置,并返回位置对应的索引. 思路 设定.sort()需要的返回函数 将要搜索的值添加到数组内 用. ...

  3. spring bean的介绍以及xml和注解的配置方法

    5.Bean 下边我们来了解一下Bean的: Bean的作用域Bean的生命周期Bean的自动装配Resources和ResourceLoader 5.1Bean容器的初始化 Bean容器的初始化 两 ...

  4. python入门:py2.x里面除法或乘法这么写就可以计算小数点后面结果

    #!/usr/bin/env python # -*- coding:utf-8 -*- #py2.x里面除法或乘法这么写就可以计算小数点后面结果,更精确future(未来,译音:非忧车) divis ...

  5. 【mysql】mysql has gone away

    原文 http://www.jb51.net/article/23781.htm MySQL server has gone away 问题的解决方法 投稿:mdxy-dxy 字体:[增加 减小] 类 ...

  6. Python简单试题2

    1,给定一组数据,将奇数进行从小到大排序,偶数在原位置不变 例: 原数据:[5, 3, 2, 8, 1, 4]   排序后:[5, 3, 2, 8, 1, 4] 若数组为空,则返回空数组. 代码如下: ...

  7. 如何把list当成栈或者队列来用

    在python里,list和在C.java里的数组差不多,但是python里的list是可变长的,而且python语言也支持倒叙读取,如list[-1]可以读取最后一个元素.但这还不是最厉害的,lis ...

  8. python2与python3的bytes问题

    >>> s = '编程' >>> print s 编程 >>> s '\xe7\xbc\x96\xe7\xa8\x8b' >>> ...

  9. HDU:1251-统计难题(字典树模板,动态建树,静态建树)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1251 统计难题 Time Limit: 4000/2000 MS (Java/Others) Memor ...

  10. cf 1006E

    #include <iostream> #include <cstdio> #include <cstring> #include <string> # ...