Files
python/TangDou/LanQiaoBei/LanQiaoBei13ShengSai_ZJ_II/6_2.cpp

63 lines
1.3 KiB
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
/*
测试用例:
5 6
1 0 1 0 0 0
0 1 0 1 0 0
1 0 0 0 1 0
0 1 0 0 0 1
1 0 1 0 0 0
测试用例II:
5 6
1 0 1 0 0 0 2 0 4 0 0 0
0 1 0 1 1 0 0 1 0 3 1 0
1 0 0 0 1 0 3 0 0 0 2 0
0 1 0 0 0 1 0 2 0 0 0 1
1 0 1 0 0 0 1 0 1 0 0 0
5 6
1 0 1 0 0 0
0 1 0 1 1 0
1 0 0 0 1 0
0 1 0 0 0 1
1 0 1 0 0 0
测试用例III:
5 6
1 0 1 0 0 0
0 1 0 1 1 0
1 0 0 0 1 0
0 1 0 1 0 1
1 0 1 0 1 0
*/
using namespace std;
const int N = 110;
int a[N][N];
int res;
int main() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cin >> a[i][j];
//直接在原数组上递推
for (int i = n; i >= 1; i--) //从倒数第二行开始
for (int j = 1; j <= m; j++) //这个需要考虑一下边界问题
if (a[i][j]) //只有当前位置大于0才有考虑的价值
a[i][j] += a[i + 1][j + 1]; //递推式
cout << "====================" << endl;
//打印出这个新的递推数组看看是什么情况
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++)
cout << a[i][j] << " ";
cout << endl;
}
return 0;
}