hdu3714 Error Curves
题目:
Error Curves
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1151 Accepted Submission(s): 440
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
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的更多相关文章
- HDU-3714 Error Curves(凸函数求极值)
Error Curves Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- 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|, ...
- 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 ...
- Error Curves HDU - 3714
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 ...
- 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/UVA1476 Error Curves
Error Curves Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
随机推荐
- java8 stream取出 最大值/最小值
注:转载请注明出处!!! 这里直接用取出多个对象中某个值 最大/最小 来进行举例 直接看代码 /** * 时间测试类 */ class TimeTest { private Date time; pu ...
- KMP字符串匹配 模板 洛谷 P3375
KMP字符串匹配 模板 洛谷 P3375 题意 如题,给出两个字符串s1和s2,其中s2为s1的子串,求出s2在s1中所有出现的位置. 为了减少骗分的情况,接下来还要输出子串的前缀数组next.(如果 ...
- centos7yum安装VirtualBox
cd 进入目录:/etc/yum.repos.d 新建一个文件virtualbox.repo, 输入如下内容: [virtualbox] name=Oracle Linux / RHEL / Cent ...
- django商城项目之用sentry管理日志
之前写商城项目的时候,采用的日志处理方式为在终端输出或者写入文件,这样的话,项目部署上线之后,若服务器出现错误,需要到服务器查看相关的错误日志,很不方便.后期在学习别人开源项目的时候,学习到一个开源的 ...
- SCUT - 485 - 质因数计数 - 原根
https://scut.online/p/485 给定a和n,求有多少个质数p,满足n是使得a^n=1 mod p成立的最小正整数. 翻译:求有多少个质数p,使得a模p的阶delta_m(a)是n ...
- jsonp跨域请求的方式
1.jsonp一种请求方式.用于解决一个棘手的问题: 由于浏览器具有同源策略:即可以通过后台去访问其他网站,而不能通过浏览器(ajax请求)访问其他网页或域(阻止ajax请求,但是无法阻止<sc ...
- python查询mysql中是否存在某张表(传参)
客户端输入了表的名字,服务端判断表是否存在. 参考:https://blog.csdn.net/qq_36523839/article/details/80639297 需要导入re模块: impor ...
- 百度网盘SVIP不限速Mac破解版(亲测可用)
百度网盘SVIP不限速Mac破解版(亲测可用),按照教程一步一步来就可以了,链接如下: https://mac.orsoon.com/Mac/166358.html?id=ODY0MDA2Jl8mMT ...
- Apache 的 httpd-mpm.conf 文件详解
#prefork 多路处理模块 <IfModule mpm_prefork_module> StartServers 5 #设置服务器启动时建立的子进程数量, ...
- MongoDB入门_学习目标
MongoDB的概念 MongoDB mongo 索引 集合 复制集 分片 数据均衡 MongoDB数据库搭建 搭建简单的单机服务 搭建具有冗余容错功能的复制集 搭建大规模数据集群 集群的自动部署 熟 ...