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

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


相关推荐
Nil208几秒前
golang解决单词转换
算法
我是慎独21 分钟前
VulkanSceneGraph学习教程(十一)
c++·学习
imaol130 分钟前
文件编程--标准IO
linux·运维·算法
青 春 记 忆34 分钟前
LeetCode 121. 买卖股票的最佳时机|Python 解法详解
python·算法·leetcode
stolentime1 小时前
AT_agc066_a [AGC066A] Adjacent Difference题解
c++·算法·贪心算法·构造
程序猿编码1 小时前
不用PyTorch,我用C++手写了一个能认手写数字的神经网络
c++·pytorch·神经网络·大模型
不会代码的小猴1 小时前
4. 控件学习2
开发语言·c++·笔记·qt
渣波1 小时前
深度解析:LeetCode 51. N 皇后 —— 回溯算法的巅峰之作
算法
咪饭只吃一小碗1 小时前
# C++ STL 常用容器方法全面总结vector / map / set / unordered_map / unordered_set
算法
daad7771 小时前
802.11 前导码与 STF 深度解析(含检测算法与 5G 对比
人工智能·算法·5g·wifi·802.11·前导码