HDU 3714/UVA1476 Error Curves
Error Curves
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 4137 Accepted Submission(s): 1549
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?
1
2 0 0
2
2 0 0
2 -4 2
/* ***********************************************
Author :pk28
Created Time :2015/8/22 16:15:00
File Name :4.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10000+10
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << ;
const double eps=1e-;
using namespace std;
struct node{
double a,b,c;
}nod[maxn];
int n;
bool cmp(int a,int b){
return a>b;
}
double check(double x){
double Max=-INF;
for(int i=;i<=n;i++){
double tmp=nod[i].a*x*x+nod[i].b*x+nod[i].c;
if(tmp>Max)Max=tmp;
}
return Max;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int t;
cin>>t;
while(t--){
cin>>n;
for(int i=;i<=n;i++){
scanf("%lf%lf%lf",&nod[i].a,&nod[i].b,&nod[i].c);
}
double mid,mmid,l=0.0,r=1000.0,ans;
while(r-l>eps){
mid=(l+r)/,;
mmid=(mid+r)/2.0;
double t1=check(mid);
double t2=check(mmid);
if(t1<t2){
ans=t1;
r=mmid;
}
else{
ans=t2;
l=mid;
}
}
printf("%.4lf\n",ans);
}
return ;
}
精度1e-9 1e-10
HDU 3714/UVA1476 Error Curves的更多相关文章
- UVa1476 Error Curves
画出函数图像后,发现是一个类似V字型的图. 可以用三分法找图像最低点 WA了一串,之后发现是读入优化迷之被卡. /*by SilverN*/ #include<iostream> #inc ...
- Error Curves HDU - 3714
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 ...
- HDU 3714 Error Curves
Error Curves 思路:这个题的思路和上一个题的思路一样,但是这个题目卡精度,要在计算时,卡到1e-9. #include<cstdio> #include<cstring& ...
- 三分 HDOJ 3714 Error Curves
题目传送门 /* 三分:凹(凸)函数求极值 */ #include <cstdio> #include <algorithm> #include <cstring> ...
- Error Curves(2010成都现场赛题)
F - Error Curves Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Descript ...
- 【单峰函数,三分搜索算法(Ternary_Search)】UVa 1476 - Error Curves
Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a m ...
- UVA 5009 Error Curves
Problem Description Josephina is a clever girl and addicted to Machine Learning recently. She pays m ...
随机推荐
- bzoj1063【Noi2008】道路设计
题意:http://www.lydsy.com/JudgeOnline/problem.php?id=1063 用一种划分方式将树划为重链和轻链,使得所有点到根节点的路径经过的轻链最大值最小 sol: ...
- 刷题总结——table(ssoi)
题目: 题目背景 SOURCE:NOIP2016-RZZ-2 T2 题目描述 给定一个 n×m 的矩阵,行列均从 1 开始标号. 一个矩阵被认为是稳定的,当且仅当对于任意的 2≤i≤n,第 i 行的数 ...
- MySQL-JDBC Loadbalance深入解析
背景说明 公司的整个电商系统搭建在华为云上,根据老总的估计,上线3个月之后日订单量会达到百万级别,保守估计3个月之后总订单个数预计会有5千万.MySQL单表达到千万级别,就会出现明显的性能问题.根据如 ...
- PhpStorm8 注册码
User Name : EMBRACE License Key : ===== LICENSE BEGIN =====43136-1204201000002UsvSON704l"dILe ...
- PXE+Kickstart 自动安装CentOS系统
PXE (preboot execcute environment) 依赖服务 dhcp tftp file server (yum repository) 准备TFTP服务器 如何配置TFTP服务 ...
- vue搭建cli脚手架环境(出现问题及解决,主要是node版本低)
Vue 提供了一个官方的cli,为单页面应用 (SPA) 快速搭建繁杂的脚手架. 一.vue cli脚手架 脚手架通过webpack搭建开发环境 使用ES6语法 打包压缩js为一个文件 项目文件在环境 ...
- 实验十二 swing图形界面设计
1.源程序 package information;import java.awt.Container;import java.awt.FlowLayout;import java.awt.event ...
- BZOJ3786 星际探索
@(BZOJ)[DFS序, Splay] Description 物理学家小C的研究正遇到某个瓶颈. 他正在研究的是一个星系,这个星系中有n个星球,其中有一个主星球(方便起见我们默认其为1号星球),其 ...
- IOS --关于粘贴板 ,剪切板 ,UILabel的复制
在iOS中下面三个控件,自身就有复制-粘贴的功能: 1.UITextView 2.UITextField 3.UIWebView UIKit framework提供了几个类和协议方便我们在自己的应用程 ...
- Webstorm上面通过babel将es6转化为es5
1.首先创建一个新的文件夹(名为do);2.然后再根目录下面新建一个package.json,只需要写明两个属性即name和version,这个没有必须要和下面我写的一致,可以自行定义. { &quo ...