标签:des style http os io 数据 for ar
Description
Input
Output
Sample Input
1 6 6 4 5 6 6 4 3 2 2 3 1 7 2 1 1 4 6 2 7 5 8 4 3 9 5 7 6 6 2 1 5 3 1 1 3 7 2
Sample Output
3948
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<limits.h> using namespace std; const int maxn=110; int mp[maxn][maxn]; int dp[maxn][maxn]; int t,n,m; int ok(int x,int y) { if(x<1||x>n||y<1||y>m) return 1; else return 0; } int dfs(int x,int y) { if(dp[x][y]>=0) return dp[x][y]; dp[x][y]=0; for(int i=0;i<=mp[x][y];i++) { for(int j=0;j<=mp[x][y]-i;j++)//枚举可以到达的点 { if(ok(x+i,y+j)) continue; dp[x][y]+=dfs(x+i,y+j)%10000; } } return dp[x][y]; } int main() { scanf("%d",&t); while(t--) { scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) scanf("%d",&mp[i][j]); } memset(dp,-1,sizeof(dp)); dp[n][m]=1; printf("%d\n",dfs(1,1)%10000); } return 0; }
HDU 1978 How many ways(记忆化),布布扣,bubuko.com
标签:des style http os io 数据 for ar
原文地址:http://blog.csdn.net/u013582254/article/details/38621277