标签:des style blog http java color
Time Limit: 1000/1000 MS
(Java/Others) Memory Limit: 32768/32768 K
(Java/Others)
Total Submission(s): 2637 Accepted
Submission(s): 1707
状态转移方程: dp[i][j]=dp[i-1][j-1]+dp[i-1][j+1];
1 //0MS 268K 512 B C++ 2 #include<stdio.h> 3 #include<string.h> 4 int main(void) 5 { 6 int dp[100][100]; //dp[i][j]第i分钟在第j棵树 7 int n,p,m,t; 8 while(scanf("%d%d%d%d",&n,&p,&m,&t)!=EOF) 9 { 10 memset(dp,0,sizeof(dp)); 11 dp[0][p]=1; 12 for(int i=1;i<=m;i++){ //时间 13 dp[i][1]=dp[i-1][2]; 14 dp[i][n]=dp[i-1][n-1]; 15 for(int j=2;j<n;j++) //位置 16 dp[i][j]=dp[i-1][j-1]+dp[i-1][j+1]; 17 } 18 printf("%d\n",dp[m][t]); 19 } 20 return 0; 21 }
hdu 2151 Worm (DP),码迷,mamicode.com
标签:des style blog http java color
原文地址:http://www.cnblogs.com/GO-NO-1/p/3702950.html