三分 HDOJ 3714 Error Curves
/*
三分:凹(凸)函数求极值
*/
#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的更多相关文章
- 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 ...
- HDU 3714 Error Curves
Error Curves 思路:这个题的思路和上一个题的思路一样,但是这个题目卡精度,要在计算时,卡到1e-9. #include<cstdio> #include<cstring& ...
- 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在定义域中 ...
- 【单峰函数,三分搜索算法(Ternary_Search)】UVa 1476 - Error Curves
Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a m ...
- Error Curves HDU - 3714
Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a m ...
- UVA - 1476 Error Curves 三分
Error Curves Josephina is a clever girl and addicted to Machi ...
- HDU 3714/UVA1476 Error Curves
Error Curves Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
随机推荐
- [K/3Cloud] 树形单据体的应用说明
1.BOSIDE制作单据,支持动态表单,单据,基础资料,报表等域模型. 2.添加列,和原来单据体一样. 3.设置主键列名,父级主键字段名,行类型字段名,节点图片字段名(没有可以为空) 4.运行时展 ...
- NOIP2012 文化之旅
题目描述 Description 有一位使者要游历各国,他每到一个国家,都能学到一种文化,但他不愿意学习任何一种文化超过一次(即如果他学习了某种文化,则他就不能到达其他有这种文化的国家).不同的国家可 ...
- linux 磁盘配额配置
1. 添加一块新磁盘 ,分区 .格式化 .(mkfs.etx3 /dev/sdc5/) 2.设置开机自动挂载(vi /etc/fstab) 添加磁盘配额支持 (用户配额usrquota.组配额grpq ...
- poj_2586_Y2K Accounting Bug_201407211318
Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10210 Accepted: 50 ...
- 2017-10-01-afternoon
T1 一道图论好题(graph) Time Limit:1000ms Memory Limit:128MB 题目描述 LYK有一张无向图G={V,E},这张无向图有n个点m条边组成.并且这是一张带 ...
- UVALive7042(博弈论)
题意: Bob和Alice在有向图内玩游戏,n个顶点,m条边. 每人一颗棋子,初始位置分别是x,y. Bob先手,轮流操作,每次只能走一条有向边. 结束条件: 1.不能操作的人输 2.两个棋子重合Bo ...
- Servlet实现页面重定向
以下内容引用自http://wiki.jikexueyuan.com/project/servlet/page-redirect.html: 当文档移动到一个新的位置时,通常会使用页面重定向,需要将客 ...
- [转载]【BlackHat 2017】美国黑客大会首日议题汇总,演讲PPT下载也在这里
今年是 Black Hat 举办的第 20 个年头,高温酷暑也挡不住全世界黑客和安全人员奔赴拉斯维加斯的热情.毕竟这可是一年一度的盛大狂欢啊.今年的 BHUSA 从美国东部时间时间 7 月 22 日( ...
- [AngularJS] ocLazyLoad -- Lazy loaded module should contain all the dependencies code
Recentlly works with AngularJS + ocLazyLoad, our project have break down into multi small modules. F ...
- C# .NET using ManagementObjectSearcher提示缺少引用怎么办
在下图中,即使引用了System.Management还是会出现报错 其实只要添加这条引用就可以了