路径计数 - 题目 - Daimayuan Online Judge
AC代码:
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <stdio.h>
#define int long long
using namespace std;
const int mod = 1e9+7;
int dp[110][110];
bool st[110][110];
signed main() {
int n;cin>>n;
memset(dp, 0, sizeof(dp));
dp[0][1]=1;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
cin>>st[i][j];
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(st[i][j]) {
dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
}
}
}
cout<<dp[n][n]%mod<<endl;
}