[GESP202503 四级] 二阶矩阵

从这题中我们可以找到一个关键:

我们历遍每个元素,去找他的一些对应的元素。最后去判断。

注意:去判断时,i 和 j 时小于 n 和 m,不要弄成小于等于了。

代码

cpp 复制代码
#include <bits/stdc++.h>
using namespace std;
int a[505][505];
int main(){
	int n,m,cnt=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<m;j++){
			if(a[i][j]*a[i+1][j+1]==a[i+1][j]*a[i][j+1]){
				cnt++;
			}
		}
	}
	cout<<cnt;
	return 0;
}
相关推荐
hz_zhangrl2 天前
CCF-GESP 等级考试 2025年6月认证C++六级真题解析
c++·青少年编程·程序设计·gesp·gesp2025年6月·c++六级
王老师青少年编程2 天前
2025年6月GESP(C++六级):学习小组
数据结构·c++·算法·gesp·六级·学习小组
hz_zhangrl14 天前
CCF-GESP 等级考试 2025年6月认证C++三级真题解析
开发语言·c++·青少年编程·gesp·gesp2025年6月·c++三级
mochensage1 个月前
关于计算机基础知识的详细讲解(从属GESP一级内容)
gesp
No0d1es3 个月前
青少年编程考试 CCF GESP图形化编程 一级认证真题 2025年3月
青少年编程·scratch·gesp·一级·ccf
No0d1es3 个月前
青少年编程考试 CCF GESP图形化编程 二级认证真题 2025年3月
青少年编程·scratch·等级考试·gesp·图形化·ccf·二级
No0d1es3 个月前
青少年编程考试 CCF GESP图形化编程 三级认证真题 2025年3月
青少年编程·scratch·等级考试·gesp·图形化·ccf·三级
No0d1es4 个月前
青少年编程考试 CCF GESP Python五级认证真题 2025年3月
python·青少年编程·等级考试·gesp·ccf·五级
No0d1es4 个月前
CCF GESP Python编程 三级认证真题 2025年3月
python·青少年编程·gesp·ccf·三级
No0d1es4 个月前
CCF GESP C++编程 四级认证真题 2025年3月
开发语言·c++·青少年编程·gesp·ccf·四级·202503