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 ...
随机推荐
- JMeter创建FTP测试
FTP服务主要提供上传和下载功能.有时间需要我们测试服务器上传和下载的性能.在这里我通过JMeter做一个FTP测试计划的例子. * 使用的是JMeter2.4版本. * 测试的服务器是IP:124. ...
- Laravel Eloquent ORM
Eloquent ORM 简介 基本用法 集体赋值 插入.更新.删除 软删除 时间戳 查询范围 关系 查询关系 预先加载 插入相关模型 触发父模型时间戳 与数据透视表工作 集合 访问器和调整器 日期调 ...
- 阿里云安装docker
选centos6.5输入操作系统 yum install docker-io docker -d 提示没有备用IP地址可以用来桥接卡 接下来的网卡中编辑eth0 DEVICE=eth0 ONBOOT ...
- Difference between enabled and userInteractionEnabled properties
I read through the documentation, and here are my findings. UIButton inherits from UIControl the boo ...
- DIV 与 Table 嵌套
当然可以了.对于DIV定义表示一块可显示 HTML 的区域. Specifies a container that renders HTML. 注释此元素在 Internet Explorer 3.0 ...
- Android Studio IDE 所遇问题汇总
[窗体视图无法显示] 在/res/values/styles.xml文件中,修改一下内容 <!-- Base application theme. --><style nam ...
- C#基础之方法参数
params params 关键字可以指定在参数数目可变处采用参数的方法参数. 在方法声明中的 params 关键字之后不允许任何其他参数,并且在方法声明中只允许一个 params 关键字 publi ...
- <经验杂谈>C#中一种最简单、最基本的反射(Reflection):通过反射获取方法函数
说起反射之前和很多用C#/.net的同仁们一样,相比于一般应用层对数据的增删改查总有点觉得深奥到难以理解.其实程序这东西,用过.实践过就很简单,我一直这么认为. 先说下概念:反射 Reflection ...
- (转)C#之玩转反射
前言 之所以要写这篇关于C#反射的随笔,起因有两个: 第一个是自己开发的网站需要用到 其次就是没看到这方面比较好的文章. 所以下定决心自己写一篇,废话不多说开始进入正题. 前期准备 在VS20 ...
- linq读书笔记1-linq 初步
至于linq是什么之类的已经有过太多的文章介绍,亦不清楚的胡朋友可以自己搜索一下便可以得到大量的答案 为了体验linq究竟能带给我们什么体验,我们直接从代码入手: string[] words = n ...