码迷,mamicode.com
首页 > Web开发 > 详细

【题解】JSOI2011分特产

时间:2018-12-21 21:11:25      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:bsp   using   getch   sign   space   namespace   code   getchar   hellip   

没sa可suo的,sui题一道……

#include <bits/stdc++.h>
using namespace std;
#define maxn 3000
#define mod 1000000007
#define int long long
int n, m, ans, a[maxn], C[maxn][maxn];

int read()
{
    int x = 0, k = 1;
    char c; c = getchar();
    while(c < 0 || c > 9) { if(c == -) k = -1; c = getchar(); }
    while(c >= 0 && c <= 9) x = x * 10 + c - 0, c = getchar();
    return x * k;
}

void Pre()
{
    for(int i = 0; i < maxn; i ++) C[i][0] = 1;
    for(int i = 1; i < maxn; i ++)
        for(int j = 1; j < maxn; j ++)
            C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
}

int Up(int &x, int y) { x = (x + y) % mod; }
int Get(int x)
{
    int ret = 1;
    for(int i = 1; i <= m; i ++) 
        ret = ret * C[n - x + a[i] - 1][n - x - 1] % mod;
    return ret;
}

signed main()
{
    n = read(), m = read(); Pre();
    for(int i = 1; i <= m; i ++) a[i] = read();
    for(int i = 0; i <= n; i ++) 
    {
        int t = C[n][i] * Get(i) % mod;
        Up(ans, (i & 1) ? -t : t);
    }
    printf("%lld\n", (ans + mod) % mod);
    return 0;
}

 

【题解】JSOI2011分特产

标签:bsp   using   getch   sign   space   namespace   code   getchar   hellip   

原文地址:https://www.cnblogs.com/twilight-sx/p/10158736.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!