现在的位置: 首页 > 综合 > 正文

hdu1978

2014年02月11日 ⁄ 综合 ⁄ 共 517字 ⁄ 字号 评论关闭
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<iomanip>
#define INF 99999999
using namespace std;

const int MAX=101;
int s[MAX][MAX];
int mod=10000;

int main(){
	int n,m,a,t;
	cin>>t;
	while(t--){
	    cin>>n>>m;
		memset(s,0,sizeof s);
		s[0][0]=1;
		for(int i=0;i<n;++i){
			for(int j=0;j<m;++j){
				cin>>a;
				for(int x=0;x<=a;++x){
					if(i+x<n){
						for(int y=0;y<=a-x;++y){
							if(x == 0 && y == 0)continue;
							if(j+y<m)s[i+x][j+y]=(s[i+x][j+y]+s[i][j])%mod;
						}
					}
				}
			}
		}
		cout<<s[n-1][m-1]<<endl;
	}
	return 0;
}

抱歉!评论已关闭.