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;
}
保姆级教程:用GMT6.1绘制专业地形起伏图(从数据下载到出图避坑) 本文提供了一份详细的GMT6.1绘制地形起伏图的保姆级教程,从环境搭建到数据下载,再到核心绘图命令解析,帮助用户避开常见错误。特别适合科研人员和地理信息爱好者快速掌握专业地形图的绘制技巧,提升工作效率。 阅读详情

相关推荐

智能体评测技术与实践:从评估维度到DeepEval实战指南

智能体评测技术与实践:从评估维度到DeepEval实战指南 本文系统探讨了AI智能体的评测体系与实践方法。首先从四个关键维度构建评估框架:基础能力(意图理解、知识完整性)、复杂任务(多轮对话、动态工作流)、可靠性(幻觉抑制、安全合规)以及工具效率(参数填充、多工具协同)。其次分析了主流评测工具,包括xBench的动态双轨评估、DeepEval的全链路监控等解决方案。最后详细介绍了DeepEval的实战应用,涵盖环境配置、测试用例构建、指标配置及CI/CD集成,展示了如何通过代码化评估实现智能体质量的持续提升

Linda的自动化测试之旅 3419

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的博客 476

高德地图开放平台Web服务API调用全解析:从申请Key到获取POI数据的完整流程

本文详细解析高德地图开放平台Web服务API的合规使用流程,从开发者账号注册、Key类型选择到POI数据采集方案构建。重点介绍文本搜索接口的三种查询模式及高级筛选技巧,提供配额管理与性能优化方案,并分享商业应用场景实战经验,帮助开发者合法高效获取POI数据。

weixin_26950847的博客 1353

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

西安交通大学SQ轴承数据集(文末附数据)

西安交通大学SQ轴承数据集

qq_43271683的博客 1万+

LwIP TCP Client 解决长数据发送的困扰

问题描述 LWIP 的 TCP Client 发送数据可以调用 tcp_write() 函数,将数据储存在缓冲区里面,然后等待超时自动发送或者调用tcp_output()函数进行发送。 然而 tcp_write() 函数 需要发送的数据过长时,将无法发送,并返回 ERR_MEM。 tcp_write()函数解析 tcp_write()的函数代码很多,就不细看代码了, 先看tcp_write()的完整函数: err_t tcp_write(struct tcp_pcb *pcb, const void

tiantangmoke的博客 1万+

三分

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

Halcon Camera-calibration 相关算子(一)

Halcon Camera-calibration 相关算子介绍

qq_44744164的博客 1366

专题学习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

基于共识的捆绑算法CBBA在多无人机多任务调度中的实现

在捆绑过程中,每个无人机根据自己的任务清单和其他无人机的任务清单,确定一个被称为“束”的集合。通过合理的任务分配和无人机协作,CBBA算法能够实现最优的任务调度,提高了多无人机系统的效率和执行能力。在每一轮迭代中,无人机根据自己的当前任务和位置信息将任务清单发送给其他无人机,并接收其他无人机发送过来的任务清单。通过比较其他无人机的任务清单和自身的任务清单,每个无人机可以更新自己的任务分配情况。在这一步中,每个无人机根据自己选择的新任务,更新自身的任务清单,并将更新后的清单发送给其他无人机。

持续更新 1156

全面指南:PyTorch与ROCm版本兼容性及多版本环境管理

本文详细介绍了在AMD GPU上配置PyTorch开发环境的完整流程,重点解决版本兼容性和多版本ROCm环境管理问题。主要内容包括:1) PyTorch与ROCm版本对应关系查询;2) 四种查看ROCm版本的方法;3) 使用update-alternatives管理多版本ROCm;4) 环境变量配置与冲突解决方案;5) 完整的验证流程和性能测试方法。文章提供了最佳实践建议和故障排除清单,帮助开发者快速搭建稳定高效的深度学习开发环境,充分发挥AMD GPU硬件性能。通过系统化的验证流程确保各组件协同工作,解决

数字人生 607

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

把 SAP GUI 做成可维护的应用:Module Pool 基础与 Table Control 深入实战

SAP Module Pool 与 Table Control 开发要点 摘要:Module Pool 作为 SAP GUI 交互的核心技术,由程序、屏幕(Dynpro)和流逻辑(Flow Logic)组成,通过 PBO/PAI 事件驱动数据流。Table Control 是其中处理多行数据的核心控件,其开发关键在于: 正确理解 PBO/PAI 数据流机制 掌握 CXTAB_CONTROL 结构的关键属性(LINES、TOP_LINE 等) 合理设置列控制属性(CXTAB_COLUMN) 采用 LOOP W

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 243

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

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

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

三分求二次函数的极值

始往流离,终彼成章。 1996

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

三分算法+HDU - 3714 Error Curves

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

BigZong 1389

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

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

【三分】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

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

三分法求近是值 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

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 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
上一篇: 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、付费专栏及课程。

余额充值