标签:
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
1 /* 2 @author: Lev 3 @date: 4 */ 5 #include <iostream> 6 #include <cstdio> 7 #include <cmath> 8 #include <cstring> 9 #include <string> 10 #include <cstdlib> 11 #include <algorithm> 12 #include <map> 13 #include <set> 14 #include <queue> 15 #include <climits> 16 #include <deque> 17 #include <sstream> 18 #include <fstream> 19 #include <bitset> 20 #include <iomanip> 21 #define LL long long 22 #define INF 0x3f3f3f3f 23 24 using namespace std; 25 int dp[102][102],mp[102][102],n,m; 26 bool isOk(int x,int y) { 27 if(x < 0 || x >= n || y < 0 || y >= m) return false; 28 return true; 29 } 30 int dfs(int x,int y) { 31 if(dp[x][y] >= 0) return dp[x][y]; 32 dp[x][y] = 0; 33 for(int i = 0; i <= mp[x][y]; ++i) 34 for(int j = 0; j <= mp[x][y]-i; ++j) 35 if(isOk(x+i,y+j)) dp[x][y] = (dp[x][y] + dfs(x+i,y+j))%10000; 36 return dp[x][y]; 37 } 38 int main() { 39 int kase; 40 scanf("%d",&kase); 41 while(kase--) { 42 scanf("%d %d",&n,&m); 43 for(int i = 0; i < n; ++i) 44 for(int j = 0; j < m; ++j) 45 scanf("%d",mp[i]+j); 46 memset(dp,-1,sizeof(dp)); 47 dp[n-1][m-1] = 1; 48 printf("%d\n",dfs(0,0)); 49 } 50 return 0; 51 }
标签:
原文地址:http://www.cnblogs.com/crackpotisback/p/4319332.html