题目链接: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. 锋利的JQuery(三)

    事件冒泡: 解决方式: 1.使用事件对象:$("element").bind("click",function(event){}); 这个事件对象只有事件处理函 ...

  2. mirrors

    http://mirrors.163.com/http://mirrors.aliyun.com/http://mirrors.aliyun.com/centos/7.2.1511/os/x86_64 ...

  3. combotree

    1,直接获取:     单选:$("#id").combotree("getValue")     多选:$("#id").combotre ...

  4. 华硕本本重装系统后出现can not open file c:\RECOVERY.DAT

    华硕本本重装系统后出现can not open file c:\RECOVERY.DAT很多网友会觉得困惑,不知道为什么会这样,下面我就为大家来解决这个问题,方法一: 这个问题就出在华硕自带系统都是装 ...

  5. win8以上系统,设置英文为默认输入法

    说明:这里将添加“简体中文(美式键盘)”,也就是英文输入法,并设置为默认输入法. 1.打开控制面板—时钟.语言和区域—语言,点击“添加语言”,选择“英语”—打开,选择“英语(美国)” —添加. 2.选 ...

  6. 8.1:SportsStore:Orders and Administration

    本章,作者将通过收集和验证购物明细,来完成SportsStore应用,并在Deployd服务器上存储该订单.作者也构建了一个管理应用,允许认证用户查看订单,和管理产品分类. 1.准备实例项目 2.获取 ...

  7. 删除 SQL Server 2005 Express 工具

    安装sql server 2008 management,提示错误:Sql2005SsmsExpressFacet 检查是否安装了 SQL Server 2005 Express 工具. 失败,已安装 ...

  8. .Net额外小工具

    http://blog.csdn.net/zhumi/article/details/49076 用于编写单元测试的 NUnit用于创建代码文档资料的 NDoc用于生成解决方案的 NAnt用于生成代码 ...

  9. java多线程解决生产者消费者问题

    import java.util.ArrayList; import java.util.List; /** * Created by ccc on 16-4-27. */ public class ...

  10. [UML]转:UML类图集中关系的总结

    转:http://blog.csdn.net/dragonpeng2008/article/details/6836448 在UML类图中,常见的有以下几种关系: 泛化(Generalization) ...