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
画图理解一下,
几个下凸函数取max仍然是下凸函数
然后三分就行了
 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
double eps=1e-;
double a[],b[],c[];
int n;
double cal(double x)
{int i;
double tmp=a[]*x*x+b[]*x+c[];
for (i=;i<=n;i++)
{
tmp=max(tmp,a[i]*x*x+b[i]*x+c[i]);
}
return tmp;
}
int main()
{int T,i;
cin>>T;
while (T--)
{
cin>>n;
for (i=;i<=n;i++)
{
scanf("%lf%lf%lf",&a[i],&b[i],&c[i]);
}
int t=;
double l=,r=,ans=;
while (t--)
{
double mid1=l+(r-l)/3.0,mid2=r-(r-l)/3.0;
if (cal(mid1)<cal(mid2)) r=mid2;
else l=mid1;
}
printf("%.4lf\n",cal(l));
}
}

UVA 5009 Error Curves的更多相关文章

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

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

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

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

  3. UVA - 1476 Error Curves 三分

                                           Error Curves Josephina is a clever girl and addicted to Machi ...

  4. UVALive 5009 Error Curves 三分

    //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include& ...

  5. uva 1476 - Error Curves

    对x的坐标三分: #include<cstdio> #include<algorithm> #define maxn 10009 using namespace std; do ...

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

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

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

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

  8. Error Curves HDU - 3714

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

  9. hdu 3714 Error Curves(三分)

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

随机推荐

  1. 极光征文 | 写写文章就能赢 Filco,岂不美滋滋

    由极光社区举办的第二届征文大赛 --「我和极光的那些事儿」又来啦! 在简书平台发布文章并投稿至「我和极光的那些事」专题,只要参与就能 100% 获得京东购物卡,更有机会赢取象征信仰的 Filco 机械 ...

  2. 福州大学W班-个人最终成绩统计

    千帆竞发图 平时分: 项目分: 详细得分 平时分: 项目分: 个人最终得分:

  3. alpha冲刺第九天

    一.合照 二.项目燃尽图 三.项目进展 提问界面完成 财富值界面完成 四.明日规划 继续完善各个内容的界面呈现 继续查找关于如何自动更新爬取内容 五.问题困难 在呈现的时候还是一直会停止运行 爬取先暂 ...

  4. C#系统服务安装

    转载 http://blog.csdn.net/vvhesj/article/details/8349615 1.1创建WindowsService项目 导入需要的引用比如System.configu ...

  5. python-map的用法

    map()函数 map()是 Python 内置的高阶函数,它接收一个函数 f 和一个 list,并通过把函数 f 依次作用在 list 的每个元素上,得到一个新的 list 并返回. 1.当seq只 ...

  6. Mego开发文档 - 建模高级主题

    建模高级主题 在建模过程中我们还有许多其他情况,这里列出本框架中的有用特性来用于解决此类问题. 函数映射 我们可以将指定的CLR函数映射到数据库中的系统函数或自定义函数,该特性用于补充框架中未提供的数 ...

  7. jquery 实时监听输入框值变化方法

    $('.offers-number').bind('input propertychange', function (a, b) { var value = $(this).val() if (!va ...

  8. kubernetes入门(02)kubernetes的架构

    一.kubernetes的主从架构 kubectl,全称 Kubernetes Control Plane,它表示Kubernetes为了实现最终的目标而构建的一组集群范围内的进程,这组进程相互协调, ...

  9. angular2 学习笔记 ( app initialize 初始化 )

    refer : http://stackoverflow.com/questions/39033835/angularjs2-preload-server-configuration-before-t ...

  10. OAuth2.0学习(3-1)发布 spring-oauth-client 和 spring-oauth-server

    1.发布spring-oauth-server应用 1.1.创建案例数据库oauth2,root/Abc1234% 1.2.执行脚本,创建数据结构和demo数据 init_db.sql (user_用 ...