0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-16 19:45:24 +00:00

1291. 数字组合

http://ybt.ssoier.cn:8088/statusx.php?runidx=15603084
This commit is contained in:
Baoshuo Ren 2022-04-04 15:27:15 +08:00
parent 787d25df06
commit 548a8a0683
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

29
ybt/1291/1291.cpp Normal file
View File

@ -0,0 +1,29 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1005;
int n, m, a[N], f[N];
int main() {
std::ios::sync_with_stdio(false);
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;
}