Josephina is a clever girl and addicted to Machine Learning recently. She 
pays much attention to a method called Linear Discriminant Analysis, which 
has many interesting properties. 
In order to test the algorithm's efficiency, she collects many datasets. 
What's more, each data is divided into two parts: training data and test 
data. She gets the parameters of the model on training data and test the 
model on test data. To her surprise, she finds each dataset's test error curve is just a parabolic curve. A parabolic curve corresponds to a quadratic function. In mathematics, a quadratic function is a polynomial function of the form f(x) = ax2 + bx + c. The quadratic will degrade to linear function if a = 0.

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?

InputThe input contains multiple test cases. The first line is the number of cases T (T < 100). Each case begins with a number n (n ≤ 10000). Following n lines, each line contains three integers a (0 ≤ a ≤ 100), b (|b| ≤ 5000), c (|c| ≤ 5000), which mean the corresponding coefficients of a quadratic function.OutputFor each test case, output the answer in a line. Round to 4 digits after the decimal point.Sample Input

2
1
2 0 0
2
2 0 0
2 -4 2

Sample Output

0.0000
0.5000 这题给你n个二次函数,求出最大值的最小值。
其实就是n个二次取出每一个点去最大值,然后构成一个新的二次函数。
于是就变成了二次函数求最小值。
裸三分!
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int a[],b[],c[];
int n;
double f(double x)
{
double ans=a[]*x*x+b[]*x+c[];
for (int i= ;i<n ;i++){
ans=max(ans,a[i]*x*x+b[i]*x+c[i]);
}
return ans;
}
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]);
}
double l=,r=,rmid,lmid;
while(r-l>1e-){
rmid=r-(r-l)/;
lmid=l+(r-l)/;
if (f(rmid)>f(lmid)) r=rmid;
else l=lmid;
}
printf("%.4lf\n",f(l));
}
return ;
}

Error Curves HDU - 3714的更多相关文章

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

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

  2. hdu 3714 Error Curves(三分)

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

  3. HDU 3714/UVA1476 Error Curves

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

  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. Error Curves(2010成都现场赛题)

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

  7. 【单峰函数,三分搜索算法(Ternary_Search)】UVa 1476 - Error Curves

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

  8. UVA 5009 Error Curves

    Problem Description Josephina is a clever girl and addicted to Machine Learning recently. She pays m ...

  9. UVA 1476 - Error Curves(三分法)

    UVA 1476 1476 - Error Curves 题目链接 题意:给几条下凹二次函数曲线.然后问[0,1000]全部位置中,每一个位置的值为曲线中最大值的值,问全部位置的最小值是多少 思路:三 ...

随机推荐

  1. 输入url到渲染出页面的过程

    输入地址 浏览器查找域名的 IP 地址 这一步包括 DNS 具体的查找过程,包括:浏览器缓存->系统缓存->路由器缓存... 浏览器向 web 服务器发送一个 HTTP 请求 服务器的永久 ...

  2. Windows Server 2016-FSMO操作主机角色介绍

    FSMO五个操作主机角色 1.林范围操作主机角色(两种): 架构主机角色:Schema Master 域命名主机角色:Domain Naming Master 2.域范围操作主机角色(三种): 域范围 ...

  3. Jenkins代码管理

    1.1  Jenkins安装与下载应用代码   应用部署   http://jenkins-ci.org   http://wordpress.org/   http://core.svn.wordp ...

  4. docker 实践(一)

    docker 简介 容器虚拟化,比传统的虚拟化轻量 2013年出现,发展非常迅猛 Redhat在6.5版本开始支持docker 使用go语言开发,基于apache2.0协议 开源软件,项目代码在git ...

  5. dedecms实现编辑文章时不自动修改发布时间

    dedecms默认编辑文章时自动修改文章的发布时间,如何让它不自动修改发布时间呢? 找到后台编辑文章的模板文件稍作调整即可. 文件/dede/templets/artical_edit.htm 把 $ ...

  6. 编译安装python3.6后pip3无法安装模块问题处理

    编译安装python3.6之后,使用pip3命令安装第三方库效果如图所示: pip is configured with locations that require TLS/SSL, however ...

  7. 三、scrapy后续

    CrawlSpiders 通过下面的命令可以快速创建 CrawlSpider模板 的代码: scrapy genspider -t crawl tencent tencent.com 我们通过正则表达 ...

  8. C#中引用变量是否应该加ref?

    看如下代码:   void Test(T t); void Test(ref T t); 当T是值类型的时候,很好判断,第一种并不能改变方法外变量的值,需要第二种方法才可以.通过查看IL代码,可以看到 ...

  9. js中判断数组中是否含有某个字符串方法

    1.两个数组间互相校验 Var  inArray = function(arr, item) { for(var i = 0; i < arr.length; i++) { if(arr[i] ...

  10. 老男孩Python全栈开发(92天全)视频教程 自学笔记16

    day16课程内容: 装饰器: def outer(): x=10 def inner(): print(x) return innerouter()() #inner 是局部变量,10闭包:如果在一 ...