mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
P1077 [NOIP2012 普及组] 摆花
R72644809
This commit is contained in:
parent
771b935a33
commit
ed7e55aea1
37
Luogu/P1077/P1077.cpp
Normal file
37
Luogu/P1077/P1077.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include <iostream>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 105,
|
||||
mod = 1e6 + 7;
|
||||
|
||||
int n, m, a[N], f[N][N];
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
|
||||
cin >> n >> m;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i <= n; i++) {
|
||||
f[i][0] = 1;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 0; j <= a[i]; j++) {
|
||||
for (int k = 0; k <= m - j; k++) {
|
||||
if (j || k) {
|
||||
f[i][j + k] = (f[i][j + k] + f[i - 1][k]) % mod;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << f[n][m] % mod << endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user