Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- int M=1e9+7;
- int n,m;
- scanf("%d%d",&n,&m);
- int a[n][m];
- for(int i=0;i<n;i++){
- for(int j=0;j<m;j++){
- scanf("%d",&a[i][j]);
- }
- }
- long long b[n][m];
- for(int i=0;i<n;i++){
- for(int j=0;j<m;j++){
- if(a[i][j]==1){
- b[i][j]=0;
- }
- else if(i==0&&j==0) b[i][j]=1;
- else if(i==0) b[i][j]=b[i][j-1];
- else if(j==0) b[i][j]=b[i-1][j];
- else b[i][j]=(b[i-1][j]+b[i][j-1])%M;
- }
- }
- printf("%lld",b[n-1][m-1]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement