mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-18 04:32:00 +00:00
P1164 小A点菜
R40041942
This commit is contained in:
parent
41988fc322
commit
3384d136de
26
problem/P1164/P1164.cpp
Normal file
26
problem/P1164/P1164.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int n, m, a[10005], f[10005][10005];
|
||||
cin >> n >> m;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i];
|
||||
}
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= m; j++) {
|
||||
if (j == a[i]) {
|
||||
f[i][j] = f[i - 1][j] + 1;
|
||||
}
|
||||
if (j > a[i]) {
|
||||
f[i][j] = f[i - 1][j] + f[i - 1][j - a[i]];
|
||||
}
|
||||
if (j < a[i]) {
|
||||
f[i][j] = f[i - 1][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << f[n][m] << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user