Hdu3714-Error Curves(三分)
It's very easy to calculate the minimal error if there is only one test error curve. However, there are several datasets, which means Josephina will obtain many parabolic curves. Josephina wants to get the tuned parameters that make the best performance on all datasets. So she should take all error curves into account, i.e., she has to deal with many quadric functions and make a new error definition to represent the total error. Now, she focuses on the following new function's minimum which related to multiple quadric functions. The new function F(x) is defined as follows: F(x) = max(Si(x)), i = 1...n. The domain of x is [0, 1000]. Si(x) is a quadric function. Josephina wonders the minimum of F(x). Unfortunately, it's too hard for her to solve this problem. As a super programmer, can you help her?#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<utility>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iterator>
#include<stack>
using namespace std;
const int INF=1e9+;
const double eps=1e-;
const int maxn=;
int N,A[maxn],B[maxn],C[maxn];
double Cal(double mid)
{
double ret=-;
for(int i=;i<N;i++)
{
ret=max(ret,A[i]*mid*mid+B[i]*mid+C[i]);
}
return ret;
}
double solve()
{
double x=,y=,mid,midmid;
int cnt=;
while(cnt--)
{
mid=(x+y)/;
midmid=(mid+y)/;
if(Cal(mid)<Cal(midmid)) y=midmid;
else x=mid;
}
return Cal(x);
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d",&N);
for(int i=;i<N;i++) scanf("%d%d%d",&A[i],&B[i],&C[i]);
printf("%.4f\n",solve());
}
return ;
}
Hdu3714-Error Curves(三分)的更多相关文章
- UVA - 1476 Error Curves 三分
Error Curves Josephina is a clever girl and addicted to Machi ...
- HDU-3714 Error Curves(凸函数求极值)
Error Curves Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- hdu3714 Error Curves
题目: Error Curves Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- 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& ...
- HDU3714 Error Curves (单峰函数)
大意: 给你n个二次函数Si(x),F(x) = max{Si(x)} 求F(x)在[0,1000]上的最小值. S(x)=ax^2+bx+c (0<=a<=100, |b|, ...
- 【单峰函数,三分搜索算法(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 ...
随机推荐
- poj 3666 Making the Grade(dp)
Description A straight dirt road connects two fields on FJ's farm, but it changes elevation more tha ...
- hdu 5422 Rikka with Graph(简单题)
Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he ...
- 使用python监听、模拟鼠标键盘事件
最近守望职业选手疑似开挂事件挺热闹的,在下小菜一枚,并不能从视频中看出端倪.看了一些关于外挂的讨论,自动点射和压枪只需在鼠标驱动上做些改动即可,自瞄或其他高级功能则需要读内存或修改游戏文件,检测也更容 ...
- Python源码学习之初始化(三)-PyDictObject的初始化
先来看它的定义 typedef struct _dictobject PyDictObject; struct _dictobject { PyObject_HEAD Py_ssize_t ma_fi ...
- Zedboard甲诊opencv图像处理(二)
通过前面的努力已经得到了n个轮廓了,现在要把最终的轮廓确定下来 ,然后进行特征提取. 先深入分析下轮廓和处理轮廓的方法:http://blog.csdn.net/hitwengqi/article/d ...
- web工程调用hadoop集群1.2
本实例代码在lz的资源中有上传,有需要的可以参考(下载后的文件解压后有两个,一个直接导入myeclipse工程,另外的jar放在hadoop的lib下面,只需修改Utils中的ip即可运行该程序): ...
- Microsoft Dynamics CRM 2016 增强版的解决方案(CRM新特性,开发者的福利)
CRM在以前的版本中,如果你改变了一个字段(组织A)然后打算导入到其他组织(组织B),你必须创建一个解决方案,包括完整的实体,并导出导入.然而,如果其他团队成员正在相同的实体做了自定义但不想让这些变化 ...
- 用CSS3写的钟表
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- http断点续传原理
断点续传一是断点,一续传. 断点是在下载时,将下载文件分多片,同时进行多片一起下载,如果任务被暂停,暂停的位置就是断点. 续传就是未完成的下载再次开始时,会从上次的断点继续传送. 在下载(或上传)过程 ...
- SQL Server链接MySQL实践
最近在访问多数据库的时候进行了SQLServer链接MySQL数据的实践,现总结如下: 一. 安装mysql-connector-odbc驱动: 1. 在SQL Server服务器的机器上安装mys ...