mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
278. 数字组合
https://www.acwing.com/problem/content/submission/code_detail/10435503/
This commit is contained in:
parent
24ef7d44f2
commit
8cb75eb6bd
25
AcWing/278/278.cpp
Normal file
25
AcWing/278/278.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include <iostream>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
#define endl '\n'
|
||||
|
||||
const int N = 105,
|
||||
M = 10005;
|
||||
|
||||
int n, m, a[N], f[M];
|
||||
|
||||
int main() {
|
||||
cin >> n >> m;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i];
|
||||
}
|
||||
f[0] = 1;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = m; j >= a[i]; j--) {
|
||||
f[j] += f[j - a[i]];
|
||||
}
|
||||
}
|
||||
cout << f[m] << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user