554C - Kyoya and Colored Balls

思路:组合数,用乘法逆元求。

代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a)) const int MOD=1e9+;
const int N=1e6+;
int a[];
ll fact[N]={}; ll qpow(ll n,ll k)
{
ll ans=;
while(k)
{
if(k&)ans=(ans*n)%MOD;
k>>=;
n=(n*n)%MOD;
}
return ans;
} ll C(ll n,ll k)
{
ll ans=fact[n];
ans=((ans*qpow(fact[n-k],MOD-))%MOD*qpow(fact[k],MOD-))%MOD;
return ans;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n,sum=;
cin>>n;
for(int i=;i<=n;i++)cin>>a[i],sum+=a[i]; for(ll i=;i<N;i++)
fact[i]=(fact[i-]*i)%MOD; ll ans=;
for(int i=n;i>=;i--)
{
ans=(ans*C(sum-,a[i]-))%MOD;
sum-=a[i];
} cout<<ans<<endl;
return ;
}

554C - Kyoya and Colored Balls的更多相关文章

  1. Codeforces554 C Kyoya and Colored Balls

    C. Kyoya and Colored Balls Time Limit: 2000ms Memory Limit: 262144KB 64-bit integer IO format: %I64d ...

  2. Codeforces Round #309 (Div. 2) C. Kyoya and Colored Balls 排列组合

    C. Kyoya and Colored Balls Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...

  3. Kyoya and Colored Balls(组合数)

    Kyoya and Colored Balls time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  4. C. Kyoya and Colored Balls(Codeforces Round #309 (Div. 2))

    C. Kyoya and Colored Balls Kyoya Ootori has a bag with n colored balls that are colored with k diffe ...

  5. codeforces 553A A. Kyoya and Colored Balls(组合数学+dp)

    题目链接: A. Kyoya and Colored Balls time limit per test 2 seconds memory limit per test 256 megabytes i ...

  6. CF-weekly4 F. Kyoya and Colored Balls

    https://codeforces.com/gym/253910/problem/F F. Kyoya and Colored Balls time limit per test 2 seconds ...

  7. Codeforces A. Kyoya and Colored Balls(分步组合)

    题目描述: Kyoya and Colored Balls time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  8. 【47.95%】【codeforces 554C】Kyoya and Colored Balls

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  9. codeforces 553A . Kyoya and Colored Balls 组合数学

    Kyoya Ootori has a bag with n colored balls that are colored with k different colors. The colors are ...

随机推荐

  1. JSON—fastJSON

    FastJSON的简介和作用? 1:基于java实现的JSON解析器和生成器 2:将java对象序列化成JSON字符串 3:将JSON字符串反序列化得到java对象 (在服务端生成java是很麻烦的事 ...

  2. html5新元素练习(1)

    1, <nav>  是专门由于菜单导航,链接导航的元素 2,  <header> 主体页面的头部,与head不同,它的内容可以显示出来 3,  <footer>页面 ...

  3. Rpgmakermv(4 )doc of TerraxLights

    我只做简要翻译. To activate the script in an area, do the following: 1. Put an event switch into the map. 2 ...

  4. uva11354 LCA+最小生成树+dp

    源自大白书 题意 有n座城市通过m条双向道路相连,每条道路都有一个危险系数.你的任务是回答若干个询问,每个询问包含一个起点s和一个终点t,要求找到一条从s到t的路,使得途径所有的边的大最大危险系数最小 ...

  5. Codeforces Round #246 (Div. 2) D E

    这题说的是给了一个字符串当前缀和后缀相同的时候就计算此时的 整个串种拥有这样的子串友多少个,没想到用KMP解 用0开头的那种类型的 KMP 今天刚好也学了一下,因为KMP的作用是找出最长前缀 KMP ...

  6. 安装vscode with springboot

    1.安装jdk8 2.下载vscode,一切按照默认配置完成安装.下载地址:https://code.visualstudio.com 3.安装完成后,运行vscode.如果没有任何反应,在命令行上运 ...

  7. Android查缺补漏(View篇)--布局文件中的“@+id”和“@id”有什么区别?

    Android布局文件中的"@+id"和"@id"有什么区别? +id表示为控件指定一个id(新增一个id),如: <cn.codingblock.vie ...

  8. Java第一次实验 20145104张家明

    Java第一次实验 实验报告 实验要求: 1.使用JDK编译.运行简单的Java程序 2.使用IDEA 编辑.编译.运行.调试Java程序 实验内容: 1.使用JDK编译.运行简单的Java程序: 2 ...

  9. 20145206邹京儒《网络对抗技术》 PC平台逆向破解

    20145206邹京儒<网络对抗技术> PC平台逆向破解 注入shellcode并执行 一.准备一段shellcode 二.设置环境 具体在终端中输入如下: apt-cache searc ...

  10. 20145333茹翔 Exp5 Adobe阅读器漏洞攻击

    20145333茹翔 Exp5 Adobe阅读器漏洞攻击 实验过程 主机为kali的ip地址为:192.168.1.111.靶机windows xp 的ip地址为:192.168.1.110 使用命令 ...