标签:分享 搜索 memset 标记 bottom ott 选择 dfs stream
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5203 Accepted Submission(s): 3067
1 #include<iostream> 2 #include<string.h> 3 4 using namespace std; 5 6 int n,m; 7 int mapp[105][105]; 8 int ji[105][105]; 9 10 int dfs(int x,int y) 11 { 12 if(x==n&&y==m) 13 return 1; 14 if(ji[x][y]>=0) 15 return ji[x][y]; 16 int con=0; 17 int neng=mapp[x][y]; 18 for(int i = 0; i <= neng; i++) 19 for(int j = 0; j <= neng; j++) 20 if(x+i<=n && y+j<=m && i+j!=0 && i+j<=neng) 21 con+=dfs(x+i,y+j),con%=10000; 22 ji[x][y]=con; 23 return con; 24 } 25 int main() 26 { 27 int t; 28 cin>>t; 29 while(t--) 30 { 31 cin>>n>>m; 32 for(int i = 1; i <= n; i++) 33 for(int j = 1; j <= m; j++) 34 cin>>mapp[i][j]; 35 memset(ji,-1,sizeof(ji)); 36 cout<<dfs(1,1)<<endl; 37 } 38 return 0; 39 }
标签:分享 搜索 memset 标记 bottom ott 选择 dfs stream
原文地址:http://www.cnblogs.com/Xycdada/p/6715487.html