Posted on 2009-04-20 10:05
superman 阅读(74)
评论(0) 编辑 收藏 引用 所属分类:
USACO
1 #include <iostream>
2
3 using namespace std;
4
5 int main()
6 {
7 freopen("money.in", "r", stdin);
8 freopen("money.out", "w", stdout);
9
10 int v, n;
11 int coin[26];
12
13 cin >> v >> n;
14 for (int i = 1; i <= v; i++)
15 cin >> coin[i];
16
17 long long cnt[26][10001] = { 0 };
18
19 for (int i = 1; i <= v; i++)
20 cnt[i][0] = 1;
21
22 for (int i = 1; i <= v; i++)
23 for (int j = 1; j <= n; j++)
24 {
25 cnt[i][j] = cnt[i - 1][j];
26 if (j - coin[i] >= 0)
27 cnt[i][j] += cnt[i][j - coin[i]];
28 }
29
30 cout << cnt[v][n] << endl;
31
32 return 0;
33 }
34