算法入门「木」迷雾森林
「木」迷雾森林
https://ac.nowcoder.com/acm/problem/53675
题意
- 类似于过河卒
思路
- 正常实现即可,注意取模
代码
#include<bits/stdc++.h>
#define N 3030
#define mod 2333
using namespace std;
int a[N][N];
long long dp[N][N];
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int n,m;
cin >> n >> m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin >> a[i][j];
}
}
dp[n][1]=1;
for(int i=n;i>=1;i--){
for(int j=1;j<=m;j++){
if(i==n&&j==1) continue;
if(a[i][j]){
dp[i][j]=0;
continue;
}
dp[i][j]=(dp[i+1][j]+dp[i][j-1])%mod;
}
}
cout << dp[1][m] << '\n';
return 0;
}