• codeforces Kyoya and Colored Balls


    题解见:http://blog.csdn.net/libin56842/article/details/46650209

    注意这里的组合数取模~~~

     1 /*Author :usedrose  */
     2 /*Created Time :2015/8/7 13:31:44*/
     3 /*File Name :2.cpp*/
     4 #pragma comment(linker, "/STACK:1024000000,1024000000") 
     5 #include <cstdio>
     6 #include <iostream>
     7 #include <algorithm>
     8 #include <sstream>
     9 #include <cstdlib>
    10 #include <cstring>
    11 #include <climits>
    12 #include <vector>
    13 #include <string>
    14 #include <ctime>
    15 #include <cmath>
    16 #include <deque>
    17 #include <queue>
    18 #include <stack>
    19 #include <set>
    20 #include <map>
    21 #define INF 0x3f3f3f3f
    22 #define eps 1e-8
    23 #define pi acos(-1.0)
    24 #define MAXN 1110
    25 #define MAXM 1000110
    26 #define OK cout << "ok" << endl;
    27 #define o(a) cout << #a << " = " << a << endl
    28 #define o1(a,b) cout << #a << " = " << a << "  " << #b << " = " << b << endl
    29 using namespace std;
    30 typedef long long LL;
    31 
    32 LL n;
    33 LL a[MAXN];
    34 LL fac[MAXM];
    35 const LL mod = 1e9+7;
    36 
    37 LL quick_pow(LL a, LL b)
    38 {
    39     LL c = 1;
    40     while (b) {
    41         if (b&1) c = c*a%mod;
    42         b >>= 1;
    43         a = a*a%mod;
    44     }
    45     return c%mod;
    46 }
    47 
    48 LL calc(LL m,LL i)
    49 {
    50     return ((fac[m]%mod)*(quick_pow((fac[i]*fac[m-i])%mod, mod-2)%mod))%mod;
    51 }
    52 
    53 int main()
    54 {
    55     //freopen("data.in","r",stdin);
    56     //freopen("data.out","w",stdout);
    57     cin.tie(0);
    58     ios::sync_with_stdio(false);
    59     fac[0] = 1;
    60     for (int i = 1;i < MAXM; ++ i)
    61         fac[i] = (fac[i-1]*i)%mod;
    62     LL ans = 1, sum = 0;
    63     cin >> n;
    64     for (int i = 1;i <= n; ++ i) {
    65         cin >> a[i];
    66         sum += a[i];
    67     }
    68     for (int i = n;i >= 1;-- i) {
    69         ans *= calc(sum-1, a[i]-1);
    70         ans %= mod;
    71         sum -= a[i];
    72     }
    73     cout << ans << endl;
    74     return 0;
    75 }
    View Code
  • 相关阅读:
    各种方便有用的文档资源的网站
    微信小程序swiper实现轮播图
    python使用小记录
    机器作曲参考
    panda读取合并表格数据并保存为pkl格式并读取
    深度学习相关的论文的下载地址
    python读取文本文件
    Python listdir获取某个目录下所有文件名
    Numpy 写3层神经网络拟合sinx
    NLP学习参考
  • 原文地址:https://www.cnblogs.com/usedrosee/p/4710555.html
Copyright © 2020-2023  润新知