题目 :Problem - 1978 (hdu.edu.cn)
#include<bits/stdc++.h>
using namespace std;
int t,n,m,a[110][110],ans[110][110];
int dfs(int x,int y){if(ans[x][y]>=0){return ans[x][y];}ans[x][y]=0;for(int i=0;i<=a[x][y];i++){for(int j=0;j<=a[x][y]-i;j++){int xx=x+i;int yy=y+j;if(xx>=1&&xx<=n&&yy>=1&&yy<=m){ans[x][y]=(dfs(xx,yy)+ans[x][y])%10000;}}}return ans[x][y];
}
int main(){scanf("%d",&t);while(t--){memset(ans,-1,sizeof ans);scanf("%d %d",&n,&m);ans[n][m]=1;for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){scanf("%d",&a[i][j]);}}printf("%d\n",dfs(1,1));}return 0;
}