题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3714

题意:求n个二次函数在[0,1000]的最小值。

三分枚举。

 #include <bits/stdc++.h>
using namespace std; const int maxn = ;
const double eps = 1e-;
double a[maxn], b[maxn], c[maxn];
int n; double f(double x) {
double ret = -;
for(int i = ; i <= n; i++) {
double y = a[i]*x*x+b[i]*x+c[i];
ret = max(ret, y);
}
return ret;
} double ts() {
double lo = , hi = 1000.0;
double ret1, ret2;
while(hi - lo >= eps) {
double mid = (lo + hi) / 2.0;
double mimid = (mid + hi) / 2.0;
ret1 = f(mid);
ret2 = f(mimid);
if(ret1 > ret2) lo = mid;
else hi = mimid;
}
return ret1;
} int main() {
//freopen("in", "r", stdin);
int T;
scanf("%d", &T);
while(T--) {
scanf("%d", &n);
for(int i = ; i <= n; i++) {
scanf("%lf %lf %lf", &a[i], &b[i], &c[i]);
}
printf("%.4lf\n", ts());
}
return ;
}

[HDOJ3714]Error Curves(三分)的更多相关文章

  1. UVA - 1476 Error Curves 三分

                                           Error Curves Josephina is a clever girl and addicted to Machi ...

  2. nyoj 1029/hdu 3714 Error Curves 三分

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3714 懂了三分思想和F(x)函数的单调性质,这题也就是水题了 #include "stdio ...

  3. hdu 3714 Error Curves(三分)

    http://acm.hdu.edu.cn/showproblem.php?pid=3714 [题意]: 题目意思看了很久很久,简单地说就是给你n个二次函数,定义域为[0,1000], 求x在定义域中 ...

  4. UVALive 5009 Error Curves 三分

    //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include& ...

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

    Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a 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. Error Curves(2010成都现场赛题)

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

随机推荐

  1. React组件开发

    目录: 属性:props 内联样式 状态记忆 : state 生命周期 访问DOM 表单输入 承接快速入门篇:http://www.cnblogs.com/jasonnode/p/4444504.ht ...

  2. UITableView(转)

    一.UITableView概述 UITableView继承自UIScrollView,可以表现为Plain和Grouped两种风格,分别如下图所示:          其中左边的是Plain风格的,右 ...

  3. android 弹幕效果demo

    记得之前有位朋友在我的公众号里问过我,像直播的那种弹幕功能该如何实现?如今直播行业确实是非常火爆啊,大大小小的公司都要涉足一下直播的领域,用斗鱼的话来讲,现在就是千播之战.而弹幕则无疑是直播功能当中最 ...

  4. 【python cookbook】【字符串与文本】11.从字符串中去掉不需要的字符

    问题:在字符串的开始.结尾或中间去掉不需要的字符,比如说空格符 解决方案: 1.字符串开始或结尾处去掉字符:str.strip() 2.从左或从右侧开始执行去除字符:str.lstrip().str. ...

  5. jquery选择器中两个class是什么意思?

    jquery选择器中两个class是什么意思? $(".class1 .class2") 选择class1元素下class2的元素(中间有空格)$(".class1.cl ...

  6. Maven创建多个子项目

    一.下载jdk并安装:下载apache-maven包,解压到指定目录.(例:D:\Java\apache-maven-3.3.9) 二.配置环境. 1.配置jdk环境 系统变量 (1)JAVA_HOM ...

  7. Docker CPU 资源限制——CPU固定核功能测试

    Docker使用Linux cgroup来实现资源的限制,对于CPU的限制有两种方法: 1.cpuset CPU Set限定容器使用某个固定的CPU核.使用默认的libcontainer引擎时,可以通 ...

  8. CGRectGet系列

    CGRectGetHeight返回label本身的高度 CGRectGetMinY返回label顶部的坐标 CGRectGetMaxY 返回label底部的坐标 CGRectGetMinX 返回lab ...

  9. mongo VUE 操作

    一  修改字段名称 db.rc_配置_付款限额_消费.update({ "生效标识" : 1, "$atomic" : "true" },{ ...

  10. C#:简单线程样例

    1.定义线程类及内部事件 using System; using System.Collections.Generic; using System.Text; using System.Threadi ...