Error Curves

思路:这个题的思路和上一个题的思路一样,但是这个题目卡精度,要在计算时,卡到1e-9。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define MAXN 10100
#define eps 1e-9
using namespace std;
int T,n;
double ans;
double l,r,mid1,mid2;
double a[MAXN],b[MAXN],c[MAXN];
double f(double x){
ans=-0x7f7f7f7f;
for(int i=;i<=n;i++) ans=max(ans,x*x*a[i]+x*b[i]+c[i]);
return ans;
}
int main(){
scanf("%d",&T);
while(T--){
scanf("%d",&n);
for(int i=;i<=n;i++)
scanf("%lf%lf%lf",&a[i],&b[i],&c[i]);
l=;r=;
while(r-l>eps){
mid1=(l+r)/;
mid2=(mid1+r)/;
if(f(mid1)>f(mid2)) l=mid1;
else r=mid2;
}
printf("%.4lf\n",f(l));
}
}

HDU 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. nyoj 1029/hdu 3714 Error Curves 三分

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

  4. hdu 3714 Error Curves(三分)

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

  5. 三分 HDOJ 3714 Error Curves

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

  6. Error Curves HDU - 3714

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

  7. HDU 3714/UVA1476 Error Curves

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

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

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

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

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

随机推荐

  1. HDU 5399 Too Simple (2015年多校比赛第9场)

    1.题目描写叙述:点击打开链接 2.解题思路:本题分情况讨论.比赛时候真是想的太简单了.以为就是(n!)^(cnt-1). 终于无限WA. 本题有几个特殊情况须要额外推断. 首先,假设输入的时候.有某 ...

  2. Unity Image Effect

    1.工作原理 Image Effect是运用于一个Camera,将Camera视见体最终看到的二维图像内容作为一个2DTexture传递给一个Shader, 然后在Shader的Fragment渲染阶 ...

  3. How to: Create Custom Configuration Sections Using ConfigurationSection

    https://msdn.microsoft.com/en-us/library/2tw134k3.aspx You can extend ASP.NET configuration settings ...

  4. Java多线程理解:线程安全的集合对象

    1.概念介绍 线程安全就是多线程访问时,采用了加锁机制,当一个线程访问该类的某个数据时,进行保护,其他线程不能进行访问直到该线程读取完,其他线程才可使用.不会出现数据不一致或者数据污染. 线程不安全就 ...

  5. linux中的raid

    参考文档 http://www.cnblogs.com/ivictor/p/6099807.html 制作raid5 http://blog.51cto.com/11134648/2103384 RA ...

  6. Lists are mutable

    The syntax for accessing the elements of a list is the same as for accessing the characters of a str ...

  7. Codeforces 667C Reberland Linguistics 记忆化搜索

    链接 Codeforces 667C Reberland Linguistics 题意 给你一个字符串,除去前5个字符串后,使剩下的串有长度为2或3的词根组成,相邻的词根不能重复.找到所有的词根 思路 ...

  8. 使用Visual Studio2012调试Redis源码

    Redis是一款C语言编写Key-Value存储系统,基于BSD协议开放源码,其源码托管在github上,大概有三万行. 源码地址:https://github.com/antirez/redis 源 ...

  9. Linux 文件系统详解

    作者: Paul Brown 译者: LCTT amwps290 这篇教程将帮你快速了解 Linux 文件系统. 早在 1996 年,在真正理解文件系统的结构之前,我就学会了如何在我崭新的 Linux ...

  10. POJ-1456 Supermarket 贪心问题 有时间限制的最小化惩罚问题

    题目链接:https://cn.vjudge.net/problem/POJ-1456 此题与HDU-1789完全是一道题 题意 有N件商品,分别给出商品的价值和销售的最后期限,只要在最后日期之前销售 ...