题目传送门

 /*
三分:凹(凸)函数求极值
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std; const int MAXN = 1e4 + ;
const int INF = 0x3f3f3f3f;
const double EPS = 0.0000000001;
struct F {
double a, b, c;
}f[MAXN];
int n; double cal(double x) {
double res = -INF;
for (int i=; i<=n; ++i) {
res = max (res, f[i].a * x * x + f[i].b * x + f[i].c);
}
return res;
} int main(void) { //HDOJ 3714 Error Curves
//freopen ("HDOJ_3714.in", "r", stdin); int T; scanf ("%d", &T);
while (T--) {
scanf ("%d", &n);
for (int i=; i<=n; ++i) {
scanf ("%lf%lf%lf", &f[i].a, &f[i].b, &f[i].c);
} double l = 0.0, r = 1000.0;
for (int i=; i<=; ++i) {
double mid = (l + r) / ;
double rmid = (mid + r) / ;
if (cal (mid) < cal (rmid)) r = rmid;
else l = mid;
}
printf ("%.4f\n", cal (r));
} return ;
}

三分 HDOJ 3714 Error Curves的更多相关文章

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

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

  2. hdu 3714 Error Curves(三分)

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

  3. HDU 3714 Error Curves

    Error Curves 思路:这个题的思路和上一个题的思路一样,但是这个题目卡精度,要在计算时,卡到1e-9. #include<cstdio> #include<cstring& ...

  4. nyoj 1029/hdu 3714 Error Curves 三分

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

  5. hdu 3714 Error Curves(三分)

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

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

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

  7. Error Curves HDU - 3714

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

  8. UVA - 1476 Error Curves 三分

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

  9. HDU 3714/UVA1476 Error Curves

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

随机推荐

  1. POJ 1769_Minimizing maximizer

    题意: 一系列m个1~n区间,每个区间固定对某个子区间进行排序,顺序选择若干区间,使最终覆盖所有区间. 分析: computes the length of the shortest subseque ...

  2. Writing Code-Codeforces511C**

    http://codeforces.com/problemset/problem/544/C 完全背包 dp[i][j]表示第i行有j个bug #include<stdio.h> #inc ...

  3. Binary Tree Postorder Traversal(各种非递归实现,完美利用栈结构模拟)

    1.后序遍历的非递归实现.(左右根) 难点:后序遍历的非递归实现是三种遍历方式中最难的一种.因为在后序遍历中,要保证左孩子和右孩子都已被访问并且左孩子在右孩子前访问才能访问根结点,这就为流程的控制带来 ...

  4. [HDU5306]Gorgeous Sequence(标记回收线段树)

    题意:维护一个序列,支持区间与一个数取min,询问区间最大,询问区间和(序列长度<=1e6) 分析: http://www.shuizilong.com/house/archives/hdu-5 ...

  5. 洛谷 P1555 尴尬的数字

    P1555 尴尬的数字 题目背景 Bessie刚刚学会了不同进制数之间的转换,但是她总是犯错误,因为她的两个前蹄不能轻松的握住钢笔. 题目描述 每当Bessie将一个数转换成新的进制时,她总会写错一位 ...

  6. WebLogic11g-创建域(Domain)及基本配置

      最近看到经常有人提问weblogic相关问题,所以闲暇之际写几篇博文(基于weblogic11),仅供大家参考. 具体weblogic的介绍以及安装,这里就不赘述了. 以域的创建开篇,虽然简单,但 ...

  7. 物理内存、虚拟内存、buffers、cached、共享内存、swap

    物理内存: 实际使用的内存: 虚拟内存: 虚拟内存是操作系统内核为了对进程地址空间进行管理(process address space management)而精心设计的一个逻辑意义上的内存空间概念. ...

  8. laravel有用的方法

    1.tinker 造假数据 factory('App\User',3)->create(); DB::table 返回collection,可以用collection中的很多方法 比如-> ...

  9. SSH端口自定义

    SSH的服务端口是22,可以定义成其他端口号, / etc/ssh/sshd_config   #ssh-server配置文件位于 /etc/init.d/ssh start   #重启SSH服务,

  10. Android网络爬虫程序(基于Jsoup)

    摘要:基于 Jsoup 实现一个 Android 的网络爬虫程序,抓取网页的内容并显示出来.写这个程序的主要目的是抓取海投网的宣讲会信息(公司.时间.地点)并在移动端显示,这样就可以随时随地的浏览在学 ...