博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
着色方案[SCOI2008] HYSBZ - 1079
阅读量:5744 次
发布时间:2019-06-18

本文共 1201 字,大约阅读时间需要 4 分钟。

1671266-20190601102709704-1884261816.png

#include
using namespace std;long long int C[100][100] = {}, A[20][100] = {};const long long int mod = 1e9 + 7;void init() { C[0][0] = 1; for (int i = 1; i < 90; ++i) { C[i][0] = C[i][i] = 1; for (int j = 1; j < i; ++j) { C[i][j] = C[i - 1][j - 1] + C[i - 1][j]; C[i][j] = C[i][j] >= mod ? C[i][j] - mod : C[i][j]; } }}long long int F(int x,int target, int t,int cnt) { long long int cnt0 = cnt - t,ans=0; for (int i = 0; i < t; ++i) { int tt = t - i,targett=target-i; if (targett <= x) ans+= C[x][x - targett] * C[cnt0 - x][tt - (x - targett)] * C[t-1][i]; } return ans;}int main() { init(); int k,t; cin >> k; int cnt = 1; A[0][0] =1; for (int i = 1; i <= k;++i) { cin >> t; cnt += t; for (int j = 0; j <= cnt; ++j) { for (int idx = max(0,j-t); idx <= j + t; ++idx) { if(A[i-1][idx]) A[i][j] = (A[i][j]+A[i - 1][idx]*F(idx, j,t,cnt))%mod; } if (j == 0 && i == k) { cout << A[k][0]; return 0; } } }}

转载于:https://www.cnblogs.com/ximelon/p/10958715.html

你可能感兴趣的文章