#include <iostream>
using namespace std;
int cnt = 0;
int arr[101][101];
int visited[101][101] = {0,};
int main() {
int n;
cin >> n;
for (int i = 0;i < n;i++) {
for (int j = 0;j < n;j++) {
cin >> arr[i][j];
// visited[i][j] = 0;
}
}
visited[0][0] = 1;
for (int i = 0;i < n;i++) {
for (int j = 0;j < n;j++) {
if (arr[i][j] == 0) {
continue;
}
if (n > arr[i][j] + i ) {
visited[i+arr[i][j]][j] += visited[i][j];
}
if ( n > arr[i][j] + j) {
visited[i][j+arr[i][j]] += visited[i][j];
}
}
}
cout << visited[n-1][n-1];
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: