#include <iostream>
using namespace std;
const int MAX = 50;
int a[MAX][MAX];
__int64 sum[MAX][MAX];
int main()
{
int n;
char ch[50];
while(cin >> n, n+1)
{
for(int i = 0; i < n; i++)
{
cin >> ch;
for(int j = 0; j < n; j++)
a[i][j] = ch[j] - '0';
}
memset(sum, 0, sizeof(sum));
sum[0][0] = 1;
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
{
if(a[i][j] == 0)
continue;
sum[i + a[i][j]][j] += sum[i][j];
sum[i][j + a[i][j]] += sum[i][j];
}
cout << sum[n-1][n-1] << endl;
}
return 0;
}
HDU 1208 Pascal's Travels
最新推荐文章于 2019-01-15 21:09:05 发布