【day55】

进阶9:

给定一个N阶矩阵A,输出A的M次幂(M是非负整数)

例如:

A =

1 2

3 4

A的2次幂

7 10

15 22

cpp 复制代码
#include<iostream>
#include<vector>
using namespace std;
int n;
vector<vector<int>>a;
vector<vector<int>>cur;
void news(int x, int y, vector<vector<int>>curtemp) {
	int s = 0;
	for (int i = 0; i < n; i++) {
		s += curtemp[x][i] * a[i][y];
	}
	cur[x][y] = s;
}
int main() {
	int m;
	cin >> n >> m;
	a.assign(n, vector<int>(n));//因为a是全局变量,需要在主函数n输入后重新分配大小,不然输入时会报错
	if (m == 0) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i == j)cout << 1;
				else cout << 0;
				if (j != n - 1)cout << " ";
			}
			cout << endl;
		}
        return 0;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	cur = a;
	vector<vector<int>>curtemp;
	for (int k = 1; k < m; k++) {
		curtemp = cur;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				news(i, j,curtemp);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cout << cur[i][j];
			if (j != n - 1)cout << " ";
		}
		cout << endl;
	}
	return 0;
}

A serial connection is a wire or set of wires used to transfer information from the CPU to an external device such as a mouse,keyboard, modem, scanner, and some types of printers. This typeof connection transfers only one piece of data at a time, and is therefore slow. The advantage of using a serial connection is that it provides effective connections over long distances.

串行连接是一根或一组电线来传送CPU的数据到外部设备,例如鼠标、键盘、调制解调器、扫描仪和一些打印机。这种类型的连接一次只能传送一组数据,所以速度很慢。使用串行连接的优势在长距离里提供有效的连接。

  • serial connection 串行连接

A parallel connection uses multiple sets of wires to transferblocks of information simultaneously. Most scanners andprinters use this type of connection. A parallel connection ismuch faster than a serial connection, but it is limited to distancesof less than 3 m (10 ft) between the CPU and the external device.

并行连接使用多组导线同时传输信息块。大多数扫描仪和打印机都采用这种连接方式。并行连接比串行连接快得多,但它限制了CPU与外部设备之间的距离必须小于3米。

Convolutional neural networks (CNNs) are among the most important models in deep learning and are widely used in computer vision tasks such as image classification, object detection, and image segmentation. Compared with traditional fully connected neural networks, CNNs significantly reduce the number of parameters by using local connections and weight sharing, which lowers computational complexity. Convolutional layers can automatically extract features from raw images, including edges, textures, and shapes. As the number of layers increases, the model is able to learn more abstract and complex feature representations. In addition, pooling layers are usually used to reduce the spatial dimensions of feature maps, thereby decreasing computational cost and improving robustness. In practical applications, CNNs have achieved remarkable success in areas such as medical image analysis, autonomous driving, and face recognition. However, training deep convolutional neural networks often requires large amounts of labeled data and powerful computing resources, which remains an important challenge in current research.

卷基神经网络在深度学习里最重要的模型之一,被广泛应用于计算机视觉任务,例如图像分类,目标检测和图像划分。相比于传统的全连接神经网络,卷积神经网络使用本地链接和权重共享来降低计算复杂度以大幅减少数量。卷积层自动从原始图像中提取特征,包括边缘,材质和形状。随着层数的增加,模型能学习更抽象和复杂的特征表现。另外,池化层通常被用于减少特征图的空间维度,减少了计算成本和提升了鲁棒性。在实际应用中卷积神经网络在多个领域已经取得了非凡的成就,比如说医药图像分析自动驾驶和人脸识别。然而训练生成卷积神经网络通常需要大量的已标签数据以及强大的计算资源,这仍然在当前研究中是一项重要的挑战。


相关推荐
wuweijianlove15 分钟前
算法复杂度估算的实验建模与可视化表达的技术6
算法
执笔画流年呀16 分钟前
7大排序算法
java·算法·排序算法
AI成长日志22 分钟前
【算法学习专栏】动态规划基础·中等两题精讲(198.打家劫舍、322.零钱兑换)
学习·算法·动态规划
计算机安禾24 分钟前
【数据结构与算法】第28篇:平衡二叉树(AVL树)
开发语言·数据结构·数据库·线性代数·算法·矩阵·visual studio
测试_AI_一辰25 分钟前
AI 如何参与 Playwright 自动化维护:一次自动修复闭环实践
人工智能·算法·ai·自动化·ai编程
未来之窗软件服务38 分钟前
算法设计—计算机等级考试—软件设计师考前备忘录—东方仙盟
算法·软件设计师·计算机等级考试
未来之窗软件服务40 分钟前
哈夫曼树构造—计算机等级考试—软件设计师考前备忘录—东方仙盟
算法·软件设计师·计算机等级考试·仙盟创梦ide·东方仙盟
kpl_201 小时前
智能指针(C++)
c++·c++11·智能指针
SUNNY_SHUN1 小时前
VLM走进农田:AgriChat覆盖3000+作物品类,607K农业视觉问答基准开源
论文阅读·人工智能·算法·开源
黎阳之光1 小时前
视频孪生赋能车路云一体化,领跑智慧高速新征程
人工智能·算法·安全·数字孪生