题目:

Error Curves

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1151    Accepted Submission(s): 440

Problem Description
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?

 
Input
The 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.
 
Output
For 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个二项式,定义F(x)为x在(0,1000)这个范围内的所有二项式的最大值,求F(x)的最小值。

#include<iostream>
#include<cstdio>
#include<cmath>
#define N 1e-15
using namespace std;
const int MAXN=;
int t,n;
int a[MAXN],b[MAXN],c[MAXN];
double hanshu(double x)
{
double y=a[]*x*x+b[]*x+c[];
for(int i=;i<n;i++)
y=max(y,a[i]*x*x+b[i]*x+c[i]);
return y;
}
int main()
{
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 left=,right=;
double mid1,mid2;
while(left+N<right)
{
mid1=(left+right)/;
mid2=(right+mid1)/;
if(hanshu(mid1)>hanshu(mid2))
left=mid1;
else right=mid2;
}
double z=hanshu(right);
printf("%.4lf\n",z);
}
return ;
}

hdu3714 Error Curves的更多相关文章

  1. HDU-3714 Error Curves(凸函数求极值)

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

  2. 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|, ...

  3. Error Curves(2010成都现场赛题)

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

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

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

  5. Error Curves HDU - 3714

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

  6. UVA 5009 Error Curves

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

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

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

  8. hdu 3714 Error Curves(三分)

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

  9. HDU 3714/UVA1476 Error Curves

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

随机推荐

  1. IDEA工具与第三方工具集成

    IDEA工具与第三方工具集成 Tomcat部署 (一)配置Tomcat ->->->配置信息 常见问题: [1]注意部署异常:java.lang.OutOfMemoryError: ...

  2. 利用coverage工具进行Python代码覆盖率测试

    Coverage是一种用于统计Python代码覆盖率的工具,通过它可以检测测试代码对被测代码的覆盖率情况. Coverage安装 1.安装命令:pip install coverage 2.查看cov ...

  3. Cassandra视图

    一.简介 Cassandra作为一个P2P结构的NOSQL数据库,使用与HBase不同的去中心化架构,在国外使用非常广泛,受欢迎程度甚至在Hbase之上.今天这篇文章介绍Cassandra在视图方面设 ...

  4. 【Python】循环结构中的else

    else在循环结构中,只有循环正常结束后才执行else,如果使用break跳出了循环,不会执行else for i in range(0,10): print(i)else: print(" ...

  5. python数据结构:pandas(2)数据操作

    一.Pandas的数据操作 0.DataFrame的数据结构 1.Series索引操作 (0)Series class Series(base.IndexOpsMixin, generic.NDFra ...

  6. C# wpf 列出文件夹所有文件

    在网上找了 cmd输入 dir "要列出的文件夹*.*" /a /b /s>"要输出的文件" 可以重定向把文件夹内容输出到文件 tree "要列 ...

  7. linux MySQL 初始化数据库

    #创建数据目录并且初始化 /bin/mysql_install_db –user=mysql

  8. Windows 开启 winrm

    # Windows 开启 winrm   ``` Enable-PSRemoting   winrm enumerate winrm/config/listener   winrm quickconf ...

  9. Linux之bash的变量

    1. 变量的显示,echo echo $变量   或    echo ${变量} eg. echo $HOME   或   echo ${HOME} 2. 变量的设置 变量的设置规则: (1)变量与变 ...

  10. [每日一学]apache camel|IBMWebsphere MQ header issue|MQRFH2 |MQSTR

    最近工作中,遇到一个很奇怪的问题: 现象:在camel开发中,通过 IBM Websphere MQ 给assasin 发送xml的message时,会多出<mcd>等这样的header出 ...