题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1978
题解:状态转移方程:dp[i+k][j+h]=(dp[i+k][j+h]+dp[i][j])%10000;
#include <stdio.h>
#include <string.h>
#define MAXN 102
int dp[MAXN][MAXN];
int main()
{
int i,j,k,h,test,n,m,x;
scanf("%d",&test);
while(test--)
{
memset(dp,0,sizeof(dp));
dp[1][1]=1;
scanf("%d %d",&n,&m);
for(i=1;i<=n;++i)
{
for(j=1;j<=m;++j)
{
scanf("%d",&x);
for(k=0;k<=x;++k)
for(h=0;k+h<=x;++h)
{
if(i+k<=n&&j+h<=m)
{
if(k==0&&h==0)
continue;
dp[i+k][j+h]=(dp[i+k][j+h]+dp[i][j])%10000;
}
}
}
}
printf("%d\n",dp[n][m]);
}
return 0;
}