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. 定时器事件QtimerEvent 随机数 qrand Qtimer定时器

    QTimerEvent类:定时器事件.QObject的子类都可使用  int QObject::startTimer(int interval)[参数:毫秒][返回值:定时器整型编号]来开启一个定时器 ...

  2. discuz $_G变量

    class.core.php中 global $_G;        $_G = array(            'uid' => 0,            'username' => ...

  3. sql 事务运用实例

    ------------------------------ create proc SaveFinancialProduct@FinancialName nvarchar(50),--产品名称@Yi ...

  4. javascript 判断数据类型

    Object.prototype.toString.call(asddfff) //报错asddfff没被定义Object.prototype.toString.call(undefined) //& ...

  5. Python3 socketserver模块

    socketserver(在Python2.*中的是SocketServer模块)是标准库中一个高级别的模块.用于简化网络客户与服务器的实现(在前面使用socket的过程中,我们先设置了socket的 ...

  6. jQuery delay() 方法

    定义和用法 delay() 方法对队列中的下一项的执行设置延迟. 语法 $(selector).delay(speed,queueName) 参数 描述 speed 可选.规定延迟的速度. 可能的值: ...

  7. Object-C-NSFileManager

    +(NSFileManager *)defaultManager;//获得文件管理对象 -(BOOL)createFileAtPath:(NSString *)path contents:(NSDat ...

  8. FastDFS单节点安装 & FastDFS+Nginx整合

    安装环境    FastDFS_v5.05.tar.gz(http://sourceforge.net/projects/fastdfs/files/)    fastdfs-nginx-module ...

  9. Confluence5.8更改数据库配置

    Confluence5.8更改数据库配置 第一步:是找到confluence的安装目录,我的安装目录在 /opt/atlassian/: 第二步:由于confluence把tomcat给改造了,所以c ...

  10. 简单的Django向HTML展示动态图片 案例——小白

    目标:通过Django向HTML传送图片展示 我的天哪,真是膈应人,网上的案例都不适合我,感觉所有的解决办法在我这里都不行. 好吧~ 是我菜,看不懂人家的代码,那句话叫啥来着?一本好经被傻和尚念歪了. ...