Time Limit: 1000/1000 MS
(Java/Others) Memory Limit: 32768/32768 K
(Java/Others)
Total Submission(s): 2584 Accepted
Submission(s): 1667
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #define MAX 105 5 using namespace std; 6 int dp[MAX][MAX]; 7 int main(){ 8 int n, t, m, p; 9 /* freopen("in.c", "r", stdin); */ 10 while(~scanf("%d%d%d%d", &n, &p, &m, &t)){ 11 memset(dp, 0, sizeof(dp)); 12 dp[1][p-1] = dp[1][p+1] = 1; 13 for(int i = 2;i <= m;i ++){ 14 for(int j = 1;j <= n;j ++){ 15 if(j > 1 && j < n) dp[i][j] += dp[i-1][j+1] + dp[i-1][j-1]; 16 else if(j == 1) dp[i][j] += dp[i-1][j+1]; 17 else dp[i][j] += dp[i-1][j-1]; 18 } 19 } 20 printf("%d\n", dp[m][t]); 21 } 22 return 0; 23 }
HDOJ --- 2151 Worm,布布扣,bubuko.com
原文:http://www.cnblogs.com/anhuizhiye/p/3628978.html