【HDOJ】4504 威威猫系列故事——篮球梦

水题。

 1 #include <cstdio>
 2 #include <cstdlib>
 3 #include <cstring>
 4 
 5 #define MAXN 25
 6 int dp[MAXN][MAXN*3];
 7 
 8 void init() {
 9     int i, j, k;
10     
11     memset(dp, 0, sizeof(dp));
12     dp[0][0] = dp[1][1] = dp[1][2] = dp[1][3] = 1;
13     for (i=2; i<MAXN; ++i) {
14         for (j=0; j<MAXN*3; ++j) {
15             dp[i][j] += dp[i-1][j-1];
16             if (j >= 2)
17                 dp[i][j] += dp[i-1][j-2];
18             if (j >= 3)
19                 dp[i][j] += dp[i-1][j-3];
20         }
21     }
22 }
23 
24 int main() {
25     int a, b, t;
26     int i, j, k, tmp;
27     int mmin, mmax;
28     __int64 ans;
29     
30     #ifndef ONLINE_JUDGE
31         freopen("data.in", "r", stdin);
32     #endif
33     
34     init();
35     
36     while (scanf("%d %d %d", &a, &b, &t) != EOF) {
37         i = t / 15;
38         j = (i+1) / 2;
39         if (b < a) {
40             tmp = a - b;
41             mmin = j;
42             mmax = j * 3;
43         } else {
44             tmp = b - a;
45             mmin = tmp + i - j + 1;
46             mmax = j * 3;
47         }
48         ans = 0;
49         for (k=mmin; k<=mmax; ++k)
50             ans += dp[j][k];
51         printf("%I64d\n", ans);
52     }
53     
54     return 0;
55 }

 

posted on 2014-12-20 14:37  Bombe  阅读(195)  评论(0编辑  收藏  举报

导航