提交时间:2023-11-25 16:56:17

运行 ID: 112339

#include<bits/stdc++.h> using namespace std; long long a[2005][2005]; int main(){ int n,m; cin>>n>>m; for (int i = 1;i <= n;i++){ for (int j = 1;j <= m;j++){ char s; cin>>s; if (s == '1'){ a[i][j] = -1; } else{ a[i][j] = 0; } } } a[1][1] = 1; for (int i = 1;i <= n;i++){ for (int j = 1;j <= m;j++){ if (a[i][j] == -1){ a[i][j] = 0; } else if (i == 1 && j != 1){ a[i][j] = a[i][j - 1]; } else if (i != 1 && j == 1){ a[i][j] = a[i - 1][j]; } else if (i != 1 && j != 1){ a[i][j] = a[i][j - 1] + a[i - 1][j]; } } } cout<<a[n][m]<<endl; return 0; }