标签:
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3296 Accepted Submission(s): 1948
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<cstdlib> #include<algorithm> using namespace std; int tt,n,m,a[110][110],dp[110][110]; int dic[4][2]={{1,0},{-1,0},{0,1},{0,-1}}; bool check(int x,int y) { if(x<1||x>n||y<1||y>m) return false; return true; } int dfs(int x,int y) { if(dp[x][y]!=-1) return dp[x][y]; dp[x][y]=0; for(int i=0;i<=a[x][y];i++) for(int j=0;j<=a[x][y]-i;j++) { int xx,yy; xx=x+i,yy=y+j; if(check(xx,yy)) { dp[x][y]=(dp[x][y]+dfs(xx,yy))%10000; } } return dp[x][y]; } int main() { scanf("%d",&tt); while(tt--) { memset(a,0,sizeof(a)); scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%d",&a[i][j]); memset(dp,-1,sizeof(dp)); dp[n][m]=1; printf("%d\n",dfs(1,1)); } return 0; }
标签:
原文地址:http://www.cnblogs.com/a972290869/p/4287079.html