[HDOJ3714]Error Curves(三分)
题目链接: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(三分)的更多相关文章
- UVA - 1476 Error Curves 三分
Error Curves Josephina is a clever girl and addicted to Machi ...
- nyoj 1029/hdu 3714 Error Curves 三分
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3714 懂了三分思想和F(x)函数的单调性质,这题也就是水题了 #include "stdio ...
- hdu 3714 Error Curves(三分)
http://acm.hdu.edu.cn/showproblem.php?pid=3714 [题意]: 题目意思看了很久很久,简单地说就是给你n个二次函数,定义域为[0,1000], 求x在定义域中 ...
- UVALive 5009 Error Curves 三分
//#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include& ...
- 【单峰函数,三分搜索算法(Ternary_Search)】UVa 1476 - Error Curves
Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a m ...
- LA 5009 (HDU 3714) Error Curves (三分)
Error Curves Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu SubmitStatusPr ...
- hdu 3714 Error Curves(三分)
Error Curves Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Tot ...
- 三分 HDOJ 3714 Error Curves
题目传送门 /* 三分:凹(凸)函数求极值 */ #include <cstdio> #include <algorithm> #include <cstring> ...
- Error Curves(2010成都现场赛题)
F - Error Curves Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Descript ...
随机推荐
- mysql单表查询&&多表查询(职员表14+9)
dept(deptno,dname,loc) emp(empno,ename,job,mgr,hiredate,sal,COMM,deptno) salgrade(grade,losal,hisal) ...
- Xcode 项目配置学习
Xcode有四种build for 分别是: build for Running build for Testing build for Profiling build for Archiving R ...
- 安装cgdb
wget -c http://cgdb.me/files/cgdb-0.6.8.tar.gz .tar.gz cd cgdb- yum -y install texinfo help2man read ...
- C#中的托管和非托管
注意!先看左上角声明!我不想误人子弟!但我不怕思考.没有思考就没有错误,互相学习,共同进步! 百度中的“专业人士”回答中出现了这句话(不知道是不是专业人士啊 百度说的)“1.是指托管代码,托管代码(M ...
- [Ogre][地形][原创]基于OgreTerrain的地形实现
需要用到的外部图片资源: 在ogre调用时需要多用到的几个外部dll: OgreTerrain_d.dll 需要添加头文件 #include "Ogre\Ogre.h"#inclu ...
- 【转】学习总结--Cookie & Session总结
转载地址:http://www.phperzone.cn/portal.php?aid=718&mod=view 一.状态管理 1)什么是状态管理? 将浏览器与web服务器之间多次交互过程 ...
- 最全面的Java多线程用法解析
1.创建线程 在Java中创建线程有两种方法:使用Thread类和使用Runnable接口.在使用Runnable接口时需要建立一个Thread实例.因此,无论是通过Thread类还是Runnable ...
- c#之委托所有方法
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cons ...
- Android动画之Interpolator和AnimationSet
AnimationSet可以加入Animation,加入之后设置AnimationSet对加入的所有Animation都有效. AnimationSet anim=new AnimationSet(t ...
- Python静态方法的使用
class Util(): @staticmethod def Func1(): print "Execute Func1!" def main(): Util.Func1()