hdu 3714 Error Curves(三分)
Error Curves
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1198 Accepted Submission(s): 460
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?
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.
1
2 0 0
2
2 0 0
2 -4 2
0.5000
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
struct node{
double a,b,c;
}que[];
double esp=1e-;
double ff(double x){
double tmax=que[].a*x*x+que[].b*x+que[].c;
for(int i=;i<n;i++){
tmax=max(tmax,que[i].a*x*x+que[i].b*x+que[i].c);
}
return tmax;
} void calculate(){
double l=,r=1000.0;
double ans1,ans2;
while(l+esp<r){
double mid=(l+r)/2.0;
double midmid=(mid+r)/2.0;
ans1=ff(mid);
ans2=ff(midmid);
if(ans1<ans2){
r=midmid;
}
else
l=mid; }
printf("%.4lf\n",ans1);
} int main(){
int t;
scanf("%d",&t);
while(t--){
memset(que,,sizeof(que));
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%lf%lf%lf",&que[i].a,&que[i].b,&que[i].c); }
calculate();
}
return ;
}
hdu 3714 Error Curves(三分)的更多相关文章
- 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在定义域中 ...
- 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 思路:这个题的思路和上一个题的思路一样,但是这个题目卡精度,要在计算时,卡到1e-9. #include<cstdio> #include<cstring& ...
- 三分 HDOJ 3714 Error Curves
题目传送门 /* 三分:凹(凸)函数求极值 */ #include <cstdio> #include <algorithm> #include <cstring> ...
- UVA - 1476 Error Curves 三分
Error Curves Josephina is a clever girl and addicted to Machi ...
- UVALive 5009 Error Curves 三分
//#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include& ...
- Error Curves HDU - 3714
Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a m ...
- HDU 3714/UVA1476 Error Curves
Error Curves Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
随机推荐
- apply()技巧
apply技巧: 可以将数组的每一项分别作为参数传入函数. var value = [3,6,34,90]; alert(Math.max.apply(Math,value)); 这个技巧的关 ...
- IOS tableView的数据刷新
1.tableView的刷新 1> 数据刷新的总体步骤 * 修改模型数据 * 刷新表格(刷新界面) 2> 刷新表格(刷新界面)的方法 * 全局刷新(每一行都会重新刷新) - (void)r ...
- 一键备份脚本 backup.sh
做网站最重要的是什么?数据!数据,是网站之本,备份,是每一个站长都应该重视的事情.但同时,备份也是一件繁琐和重复的事情.所以,这些事情,肯定能做到自动化的.下面来介绍一下这个一键备份脚本 backup ...
- 解决linux系统CentOS下调整home和根分区大小《转》
转自http://www.php114.net/2013/1019/637.html 目标:将VolGroup-lv_home缩小到20G,并将剩余的空间添加给VolGroup-lv_root 1 ...
- 快速排序算法思路分析和C++源代码(递归和非递归)
快速排序由于排序效率在同为O(N*logN)的几种排序方法中效率较高,因此经常被采用,再加上快速排序思想----分治法也确实实用,因此很多软件公司的笔试面试喜欢考这个. 快速排序是C.R.A.Hoar ...
- Bootstrap历练实例:警告框(Alert)插件事件
事件 下表列出了警告框(Alert)插件中要用到的事件.这些事件可在函数中当钩子使用. 事件 描述 实例 close.bs.alert 当调用 close 实例方法时立即触发该事件. $('#myal ...
- React报错 :browserHistory doesn't exist in react-router
由于版本问题,React中history不可用 import { hashHistory } from 'react-router' 首先应该导入react-router-dom包: import { ...
- 51nod——1285 山峰和分段(暴力出奇迹)
要求每段的点数都一样,因此分的段数cnt肯定是n的因子,要求每段都有山峰,因此cnt肯定小于等于山峰数量.分段的宽度d=n/cnt,对山峰数量做一个前缀和,检查一下每一段的山峰数量是否没有增加即可. ...
- 洛谷P3371单源最短路径Dijkstra版(链式前向星处理)
首先讲解一下链式前向星是什么.简单的来说就是用一个数组(用结构体来表示多个量)来存一张图,每一条边的出结点的编号都指向这条边同一出结点的另一个编号(怎么这么的绕) 如下面的程序就是存链式前向星.(不用 ...
- Tomcat启动xxx.keystore文件找不到
在server.xml里配置了 <Connector SSLEnabled="true" acceptCount="1000000" clientAuth ...