标签:
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
3948
#include <iostream> #include<cstdio> #include<cstdlib> #include<cstring> using namespace std; int t,n,m,i,j,ii,jj; int f[105][105],a[105][105]; int main() { scanf("%d",&t); for(;t>0;t--) { scanf("%d%d",&n,&m); for(i=1;i<=n;i++) for(j=1;j<=m;j++) scanf("%d",&a[i][j]); memset(f,0,sizeof(f)); f[1][1]=1; for(i=1;i<=n;i++) for(j=1;j<=m;j++) { for(ii=0;ii<=a[i][j];ii++) for(jj=0;jj<=a[i][j]-ii;jj++) if (i+ii<=n && j+jj<=m) { if (ii==0 && jj==0) continue; f[i+ii][j+jj]=(f[i+ii][j+jj]+f[i][j])%10000; } } /* printf("-----------\n"); for(i=1;i<=n;i++) { for(j=1;j<=m;j++) printf("%d ",f[i][j]); printf("\n"); }*/ printf("%d\n",f[n][m]); } return 0; }
hdu-1978_How many ways dfs+记忆化搜索
标签:
原文地址:http://www.cnblogs.com/stepping/p/5669076.html