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.

译文:

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

相关推荐
Js.Tx1 小时前
【具体数学 Concrete Mathematics】2.1.5 一般性的方法
算法·具体数学
秋天的怀念_David3 小时前
算法一千零一夜 · 作品相关:版权与致谢声明
程序人生·算法·学习方法
揽星河..3 小时前
【C语言】数组
c语言·开发语言·算法
careathers3 小时前
【数据结构】基于比较的排序算法 - 选择排序
数据结构·算法·排序算法
听风若依3 小时前
C++模板初阶
c++·算法
纪念 2294 小时前
C++ 算法(模拟)
开发语言·c++·算法
揽星河..4 小时前
【C语言】函数
c语言·算法
zwc32104320554 小时前
Day 2:图像内存、数据类型与stride
c++·人工智能·opencv·算法·计算机视觉
重生之小比特4 小时前
【算法拾光】模拟|提莫攻击 + N 字形变换
算法·模拟
東隅已逝,桑榆非晚5 小时前
AVL数实现
c++·笔记·学习·算法