Day52:2026年3月20日打卡

一、上机打卡

1.1 矩阵面积交

1.1.1 题目

平面上有两个矩形,它们的边平行于直角坐标系的X轴或Y轴。对于每个矩形,我们给出它的一对相对顶点的坐标,请你编程算出两个矩形的交的面积。

输入仅包含两行,每行描述一个矩形。

在每行中,给出矩形的一对相对顶点的坐标,每个点的坐标都用两个绝对值不超过10^7的实数表示。

输出仅包含一个实数,为交的面积,保留到小数后两位。

输入范例

1 1 3 3

2 2 4 4

输出范例

1.00

1.1.2 总结

两个矩形分别定义4个变量来表示矩形边界

cpp 复制代码
double x1_min, x1_max, y1_min, y1_max; //矩阵1边界
double x2_min, x2_max, y2_min, y2_max; //矩阵2边界

踩过的坑:

cpp 复制代码
//坐标大小与输入顺序无关,不能这样写:
cin >> x1_min >> y1_min >> x1_max >> y1_max;
cin >> x2_min >> y2_min >> x2_max >> y2_max;

然后计算相交矩阵的边界:

上边界为两个矩形上边界的最小值;

下边界为两个矩阵下边界的最大值;

左边界为两个矩形左边界的最大值;

右边界为两个矩形右边界的最小值;

如果满足上边界大于下边界坐标,左边界坐标小于右边界坐标,则说明存在相交矩阵。

1.1.3 代码

cpp 复制代码
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {

	double x1, x2, y1, y2; //用于接收两个点的坐标
	

	double x1_min, x1_max, y1_min, y1_max; //矩阵1边界
	double x2_min, x2_max, y2_min, y2_max; //矩阵2边界

	/*
		坐标大小与输入顺序无关,不能这样写:
		cin >> x1_min >> y1_min >> x1_max >> y1_max;
		cin >> x2_min >> y2_min >> x2_max >> y2_max;
	*/

	//输入矩阵1的坐标,计算矩阵1的最大最小边界
	cin >> x1 >> y1 >> x2 >> y2;
	x1_min = min(x1, x2);
	x1_max = max(x1, x2);
	y1_min = min(y1, y2);
	y1_max = max(y1, y2);

	//输入矩阵2的坐标,计算矩阵2的最大最小边界
	cin >> x1 >> y1 >> x2 >> y2;
	x2_min = min(x1, x2);
	x2_max = max(x1, x2);
	y2_min = min(y1, y2);
	y2_max = max(y1, y2);

	
	double top = min(y1_max, y2_max);
	double bottom = max(y1_min, y2_min);
	double left = max(x1_min, x2_min);
	double right = min(x1_max, x2_max);
	double s = 0.00;
	if (top > bottom && left < right)
		s = (top - bottom) * (right - left);
	cout << fixed << setprecision(2) << s << endl;
	return 0;
}

二、翻译打卡

原文:

In recent years, pre-trained models have played an important role in artificial intelligence research. Researchers typically first train a general model using large-scale datasets and then fine-tune it on specific tasks. In this way, the model can utilize the knowledge learned during the pre-training stage to improve the performance of downstream tasks. For example, in the field of natural language processing, many language models are pre-trained on massive text corpora and achieve excellent results in tasks such as text classification, machine translation, and question answering. The pre-training and fine-tuning framework not only reduces training costs but also improves the generalization ability of models. Therefore, this approach has become an important paradigm in modern artificial intelligence research.

译文:

最近几年,预训练模型在人工智能研究领域承担了重要的角色。研究者通常使用打过莫数据集训练一般模型,然后再特殊任务上微调它。通过这种方式,模型可以使用在预训练期间学习到的知识来提升他们在下游任务的性能。例如,在自然语言处理领域,许多语言模型是在巨大规模的文本上训练好的,并且在文本分类,机器翻译和问答任务上取得了极好的结果。预训练模型和微调框架不仅仅减少了训练成本,而且还提升了模型的泛化能力。因此,这种方法在现代人工智能研究中已经成为了一个重要的典范。

相关推荐
海清河晏11121 小时前
数据结构 | 单循环链表
数据结构·算法·链表
wuweijianlove1 天前
算法性能的渐近与非渐近行为对比的技术4
算法
_dindong1 天前
cf1091div2 C.Grid Covering(数论)
c++·算法
AI成长日志1 天前
【Agentic RL】1.1 什么是Agentic RL:从传统RL到智能体学习
人工智能·学习·算法
黎阳之光1 天前
黎阳之光:视频孪生领跑者,铸就中国数字科技全球竞争力
大数据·人工智能·算法·安全·数字孪生
skywalker_111 天前
力扣hot100-3(最长连续序列),4(移动零)
数据结构·算法·leetcode
6Hzlia1 天前
【Hot 100 刷题计划】 LeetCode 17. 电话号码的字母组合 | C++ 回溯算法经典模板
c++·算法·leetcode
wfbcg1 天前
每日算法练习:LeetCode 209. 长度最小的子数组 ✅
算法·leetcode·职场和发展
_日拱一卒1 天前
LeetCode:除了自身以外数组的乘积
数据结构·算法·leetcode
计算机安禾1 天前
【数据结构与算法】第36篇:排序大总结:稳定性、时间复杂度与适用场景
c语言·数据结构·c++·算法·链表·线性回归·visual studio