GDUT_寒假训练题解报告_专题I_K题 个人题解报告:杭电题目Error Curves【裸三分】

专题I HDU-3714 Error Curves 专题I K-三分 题面 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 ord... 阅读详情

GDUT_寒假训练题解报告_专题I_K题 个人题解报告:题目Error Curves

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3714
题目:

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

这个题应该是裸三分模板,正好让我这菜鸡练三分,首先题意,在这么多二次函数中,有一个函数F(X)叫做在x处,取所有二次函数的最大值,那么我们就能得到一个F(x)的图像,求F(x)最小值

思路步骤:

1.画图,我们可以知道两个很窄的二次函数,他们能形成一个细缝,能把几乎所有函数值给覆盖,但是也有可能被横穿过去,总之我们通过画图可以得到一个结论:F(x)函数一定一个单峰函数,有最多一个不可导点,最多一个极小值点也有是最小值点,总之是一个单峰的函数,其中最小值点也是我们的答案。

2.第一步说起来短,实际上画图步骤要得出这个结论需要一定的图像处理能力,但是也不算特别难。

------------二分和三分不同,二分定的是:这一边满足条件,那么答案一定在另一边,然后不断缩小范围,使满足条件的最大/最小点得出,但是三分不同。
------------三分用于,在一个范围内寻找最小值或者最大值,三分的思想可以如此来说明:

三分:在一段范围内:,有L,R,寻找他们中间的两个点,这时候把(l,r)分成三份,这里有两个分法;分四份取三份 和 分三份

——>分四份取三份是什么意思呢?这两个点设为mid1,和mid2
mid1=(l+r)/2,mid2=(r+mid)/2或者(l+mid)/2,
——>分三份就容易理解了:mid1=(l2+r)/3;;;mid2=(l+r2)/3

两种都是可以的,看个人写法;
三分的下一步就是判断了:
以一个凸函数为例子,找最小值(两头大中间小)
三种情况:
1.如果答案在mid1左边,那么F(mid1)<F(mid2)
2.如果答案在mid1和mid2之间,那么有F(mid1)<F(mid2)或者F(mid1)>F(mid2)
3.如果答案在mid2右边,有F(mi1)>F(mid2)
我们归类一下:
如果F(mid1)<F(mid2),那么答案在mid2左边,令r=mid2即可;
如果F(mid1)>F(mid2),那么答案在mid1右边,令l=mid1即可;

然后就是浮点型二分的结束语句while(r-l<eds){}
这个eds就是精度,

代码实现:

#define ULL unsigned long long
using namespace std;
typedef struct element
{
	double a,b,c;
}ele;

ele all[10010];

int t,n;
double f(int i,double x)
{//fi(x)的求值函数
	return all[i].a*x*x+all[i].b*x+all[i].c;
}
double F(double x)
{
	double _MAX=f(0,x);
	for(int time=1;time<n;time++)
	{
		if(f(time,x)>_MAX)_MAX=f(time,x);
	}
	return _MAX;
}

int main()
{
	scanf("%d",&t);
		for(int time=0;time<t;time++)
		{
			scanf("%d",&n);
			for(int time1=0;time1<n;time1++)
			{
				scanf("%lf %lf %lf",&all[time1].a,&all[time1].b,&all[time1].c);
			}
			double l=0;
			double r=1000;
			while(r-l>1e-9)
			{
				double mid1=(l*2+r)/3;
				double mid2=(l+r*2)/3;

				if(F(mid1)<F(mid2))r=mid2;
				else l=mid1;
			}
			printf("%.4f\n",F(l));
		}
    return 0;
}
VSLAM框架对比 格VSLAM特点介绍: (一)ORB-SLAM2 (二)ORB-SLAM3 (三)LSD-SLAM (四) 阅读详情

相关推荐

2019 GDUT 新生 专题Ⅰ K题

K - 三分 HDU - 3714 题目 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 propertie...

weixin_45794203的博客 475

前端监控性能指标

文章目录前端监控性能指标性能指标阶段性指标关键性能指标小程序W3C Level 1兼容性常规用法注意事项1、计算HTML文档请求使用 Nav Timing2、计算静态资源使用 getEntriesByType('resource') 代替 getEntries()3、secureConnectionStart 问题4、跨域资源设置响应头 Timing-Allow-Origin5、注意属性值为 0 ...

foolbird 1347

F - Problem F ( 抛物线求最小值) :UVALive - 5009

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

dianli6932的博客 239

【excel+vba】一表拆多表+不同收件人附带不同附件

快捷处理:拆分多个不同表 给不同人发送不同内容且附带附件

weixin_42779327的博客 2968

用OpenCV+ROS实现焊接机器人智能纠偏:线激光视觉的算法调参全流程

本文详细介绍了基于OpenCV和ROS的焊接机器人智能纠偏系统全流程。通过线激光视觉系统实时感知焊缝,重点解析了抗干扰图像预处理、改进的Steger算法提取激光条纹中心线,以及从2D像素到机器人基坐标系的完整坐标变换。该系统为应对焊接飞溅、弧光等复杂工况,实现高精度实时路径纠偏提供了从算法优化到工程集成的完整解决方案。

vodka的博客 159

三分

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.

Davenny:~我今天该吃点什么捏~ 406

金融波动预测:GARCH模型实战解析与ARIMA对比

本文深入解析GARCH模型在金融波动预测中的实战应用,并与传统ARIMA模型进行对比。通过沪深300指数日收益率数据的案例分析,展示GARCH模型如何有效捕捉波动聚集效应,提升极端波动预测准确率。文章包含Python代码实现、参数解读及模型选择指南,为量化交易者提供实用的波动率建模解决方案。

weixin_29098367的博客 189

专题学习1 Hproblem-Error Curve

题目 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 dataset

HakuyaZzzz的博客 490

cartographer运行错误集合

播放bag的时候错误 Check failed: sensor_to_tracking->translation().norm() < 1e-5 The IMU frame must be colocated with the tracking frame. Transforming linear acceleration into the tracking frame will otherwise be imprecise tracking frame不是imu的link 修改lua文件中的.

Studying…… 2020

15、远程操作水下航行器(ROV)的非线性控制系统设计

本文探讨了远程操作水下航行器(ROV)的非线性控制系统设计,重点介绍了多变量PID控制、改进的PD控制和滑模控制三种方法。详细阐述了各控制策略的原理、建模与仿真过程,并通过对比分析其在稳态误差、振荡、抖振及跟踪效果等方面的性能表现。文章还提出了针对不同控制方法的优化建议,并给出了选择合适控制策略的决策流程,为ROV高精度运动控制提供了系统性解决方案。

sun99的博客 156

HDU 3714 Error Curves(三分)

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 properti...

wcxyky的博客 368

IgH EtherCAT 从入门到精通:第 5 章 多主站与系统集成配置

本文介绍了 EtherCAT 多主站配置与系统集成方法。主要内容包括: 多主站实例配置原理:通过内核模块参数指定多个主站设备,每个主站独立管理一条 EtherCAT 总线,最多支持32个主站实例。 配置文件详解:在/etc/ethercat.conf中通过MASTER<X>_DEVICE变量定义各主站绑定的网卡或MAC地址,支持冗余备份配置。 系统服务集成:提供了systemd服务单元文件和传统init.d脚本两种方式实现开机自启动和管理,并建议通过override文件定制服务依赖关系。 架构示

从事嵌入式linux android驱动开发,拥有全栈能力 352

HDU-3714 Error Curves 题解*

题面: 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 t...

o·Pav的博客 343

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

HDU3714(Error Curves)三分求二次函数的极值

三分求二次函数的极值

始往流离,终彼成章。 1996

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

三分算法+HDU - 3714 Error Curves

目录 1:二分三分的区别: 2:三分算法: 3:算法模板: 4:算法的正确性分析: 1:二分三分的区别: 二分法适用于求单调的时候用的,就比如说排序好的数组,那是递增的或者递减的,三分主要用来解决单峰函数,单峰函数使用二分来做相对于三分来说并不容易,虽然我们在某些情况下可以通过求导得到单调的导函数。 2:三分算法: ...

BigZong 1389

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

UVA - 1476 Error Curves (三分搜索)

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. I

那些年 1163

hdu 3714 三分法

Error Curves Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 3158    Accepted Submission(s): 1201 Problem Description Josephina is a cl

龙腾四海365的专栏 940

HDU 3714 Error Curves(三分+模拟)

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. W

HJY 434

HDU 3714 Error Curves

Error Curves Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 860    Accepted Submission(s): 322 Problem Description Josephina is a

GooMaple 2058

【三分】Error Curves

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

wu_yihao的专栏 1342

HDU 3714 Error Curves 简单三分

题意:有一堆二次函数的系数a,b,c,自变量x的取值范围是【1,1000】问这一堆二次函数中当x取和值时使得f(x)的最小值中的最大值最小。 想法:三分x,每组系数计算一次。 #include #include #include #define eps 1e-9 using namespace std; int a[10000+5],b[10000+5],c[10000+5],

猫ER 670

LA 5009 (HDU 3714) Error Curves 翻译

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. Josephina是一个聪明的女孩

lj102800的专栏 912

HDU - 5299 Circles Game 题解

题意 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5299 给出n个不会相交不会相切的圆。Alice先手,和Bob进行博弈,每次操作可以选择一个圆,把这个圆和它所包含的圆给删掉,最后不能操作的人输。 思路 就是一个树上删边游戏,但是直接做复杂度O(n²)会TLE,所以需要圆的扫面线处理,把圆的关系转换成图,由大的圆连向它所包含的圆建边。 圆的扫描线...

JoneySun的博客 260

三分法求近是值 hdu 3714

Error Curves<br />Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)<br />Total Submission(s): 314    Accepted Submission(s): 109<br /><br />Problem DescriptionJosephina is a clever girl and addicted to Machine Learning rec

追求自由的码砖人 2350
上一篇: GDUT_寒假训练题解报告_专题I_L题 个人题解报告
下一篇: GDUT_寒假训练题解报告_专题II_B题 个人题解报告【dijkstra板子】
DevourPower
博客等级 码龄7年 52粉丝 78原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值