比赛 |
20120707 |
评测结果 |
WWWWWWWWWW |
题目名称 |
奇怪的棋盘 |
最终得分 |
0 |
用户昵称 |
CC |
运行时间 |
0.010 s |
代码语言 |
C++ |
内存使用 |
1.26 MiB |
提交时间 |
2012-07-07 11:18:45 |
显示代码纯文本
#include <cstdio>
#include <algorithm>
const int mod = 1000000007;
int n,K;
int h[505],f[505][505];
void solve() {
f[0][0] = 1;
for (int i = 1;i <= n;i++) {
f[i][0] = 1;
for (int j = 1;j <= std::min(i,K);j++) {
f[i][j] = (f[i][j] + f[i - 1][j]) % mod;
f[i][j] = (f[i][j] + (f[i - 1][j - 1] * ((h[i] - (j - 1)) % mod) % mod)) % mod;
}
}
printf("%d\n", f[n][K]);
}
int main() {
freopen("boarda.in","r",stdin);
freopen("boarda.out","w",stdout);
scanf("%d%d", &n, &K);
for (int i = 1;i <= n;i++) scanf("%d", &h[i]);
solve();
return 0;
}