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

懂了三分思想和F(x)函数的单调性质,这题也就是水题了

#include "stdio.h"  //最后得到的F(x)函数要么是单调的,要么是先减后增的,有了这个性质,就可以三分了~
#include "string.h" #define N 10005
#define eps 1e-9
#define INF 0x3fffffff struct node
{
int a;
int b;
int c;
}q[N]; int n; double S(double x)
{
double sx;
double maxt = -INF;
for(int i=0; i<n; ++i)
{
sx = q[i].a*x*x+q[i].b*x+q[i].c;
if(sx>maxt)
maxt = sx;
}
return maxt;
} int main()
{
int i,T;
double ans_mid,ans_mid_mid;
double left,right,mid,mid_mid;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(i=0; i<n; ++i)
scanf("%d %d %d",&q[i].a,&q[i].b,&q[i].c);
left = 0;
right = 1000;
while(right-left>eps)
{
mid = (right+left)/2;
ans_mid = S(mid);
mid_mid = (mid+right)/2;
ans_mid_mid = S(mid_mid);
if(ans_mid>ans_mid_mid)
left = mid;
else
right= mid_mid;
}
printf("%.4lf\n",S(right));
}
}

nyoj 1029/hdu 3714 Error Curves 三分的更多相关文章

  1. hdu 3714 Error Curves(三分)

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

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

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

  3. hdu 3714 Error Curves(三分)

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

  4. HDU 3714 Error Curves

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

  5. 三分 HDOJ 3714 Error Curves

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

  6. UVA - 1476 Error Curves 三分

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

  7. UVALive 5009 Error Curves 三分

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

  8. Error Curves HDU - 3714

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

  9. HDU 3714/UVA1476 Error Curves

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

随机推荐

  1. 线段树 + 矩阵 --- ZOJ 3772 Calculate the Function

    Calculate the Function Problem's Link:   http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCod ...

  2. MySQL主从复制与读写分离 --非原创

    原文出处:http://www.cnblogs.com/luckcs/articles/2543607.html MySQL主从复制(Master-Slave)与读写分离(MySQL-Proxy)实践 ...

  3. 批量插入数据 C# SqlBulkCopy使用

    转自:http://blog.csdn.net/wangzh300/article/details/7382506 private static void DataTableToSQLServer( ...

  4. sencha grid列tooltip提示

    grid的某一列添加renderer: renderer: function(value, metaData, record, rowIndex, colIndex, store, view) { m ...

  5. webservice 原理

    webservice 原理1.soap协议,其实就是用http协议来传输xml格式的数据,可以post,get.一般有post.2.服务端有:本地程序代码(也不是dll)和xml格式的文件用来描述dl ...

  6. 划分树---Feed the dogs

    POJ  2761 Description Wind loves pretty dogs very much, and she has n pet dogs. So Jiajia has to fee ...

  7. spring注解配置启动过程

    最近看起spring源码,突然想知道没有web.xml的配置,spring是怎么通过一个继承于AbstractAnnotationConfigDispatcherServletInitializer的 ...

  8. Python tools for Visual Studio插件介绍

          Python tools for Visual Studio是一个免费开源的VisualStudio的插件,支持 VisualStudio 2010,2012与2013.我们想要实现的是: ...

  9. 某网SQL注入漏洞实战

      root@kali:~# sqlmap -u http://dn.you.com/shop.php?id=10 -v 1 --dbs   available databases [8]: [*] ...

  10. SharePoint 2013开发环境准备一些小事项

    开发慢慢向着SharePoint 2013迁移,环境也开始慢慢准备起来了.由于FAST Search的集成,和缓存服务的加入,SharePoint 2013对开发机器要求的不是一般的高.这里介绍一下如 ...