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. 第一章SpringBoot入门

    一.简介 SpringBoot来简化Spring应用的开发,约定大于配置,去繁从简,just run就能创建一个独立的产品级别的应用. 背景: j2EE笨重的开发方法,繁多的配置,低下的开发效率,复杂 ...

  2. mysql查询表基本操作

    数据库表的创建create table <表名>( <列名> <数据类型及长度> [not null], <列名> <数据类型及长度>, . ...

  3. uva10167

    /* 暴力 过了 要使得两半的 樱桃数目相等 去试每一个斜率 还好他这里要的是 A.B 都为正整数 这样范围就锁定在200*100 个点范围内 */ #include <cstdio> # ...

  4. jquery-easyui combobox combogrid 级联不可编辑实例

    jquery-easyui combobox combogrid 级联不可编辑实例 如何让jquery-easyui的combobox像select那样不可编辑?为combobox添加editable ...

  5. 面试问题整理之python测试

    1.下列哪个语句在Python中是非法的? A.x = y = z =1 B.x = (y = z + 1) C.x, y = y, x D.x += y 答案:B 2.关于Python内存管理,下列 ...

  6. SNMP学习笔记之Linux下安装和配置SNMP

    注意:本篇安装用户是root,非root用户启动的时候会报缺少文件错误. 一.安装SNMP 1.1.下载Net-SNMP的源代码 选择一个SNMP版本,比如5.7.1,下载地址如下:http://so ...

  7. MQ内存消耗与积压分析

    [root@iZ23nn1p4mjZ logs]# rabbitmqctl status Status of node rabbit@iZ23nn1p4mjZ ... [{pid,15425}, {r ...

  8. jQuery 对象

    jQuery 对象 版权声明:未经博主授权,严禁转载分享 什么是 jQuery 对象 jQuery 对象是通过 jQuery 包装 DOM 对象后产生的对象. jQuery 对象是一个类数组对象. j ...

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

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

  10. Win32 消息响应顺序

    如果窗口处理函数响应了 WM_RBUTTONUP后,不会响应WM_CONTEXTMENU消息了.