本文共 1708 字,大约阅读时间需要 5 分钟。
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4275 Accepted Submission(s): 2499
#include#include #include #include #include #include using namespace std;const int INF=0x3f3f3f3f;#define mem(x,y) memset(x,y,sizeof(x))#define SI(x) scanf("%d",&x)#define PI(x) printf("%d",x)#define SD(x,y) scanf("%lf%lf",&x,&y)#define P_ printf(" ")const int MOD=10000;const int MAXN=110;int dp[MAXN][MAXN],mp[MAXN][MAXN];typedef long long LL;int N,M;int dfs(int x,int y){ if(dp[x][y]>=0)return dp[x][y];//之前搜索过直接返回; dp[x][y]=0; for(int i=0;i<=mp[x][y];i++) for(int j=0;j<=mp[x][y]-i;j++){//总步数为mp[x][y] if(x+i>N||y+j>M)continue; dp[x][y]=(dp[x][y]+dfs(x+i,y+j))%MOD; } return dp[x][y];}int main(){ int T; SI(T); while(T--){ SI(N);SI(M); mem(dp,-1); for(int i=1;i<=N;i++){ for(int j=1;j<=M;j++){ SI(mp[i][j]); } } dp[N][M]=1; printf("%d\n",dfs(1,1)); } return 0;}
转载地址:http://tseaz.baihongyu.com/