Codeforces Round #309 (Div. 2) C
题意:
就是给出总共同拥有k种颜色。每种颜色有ki种,排列必须满足第i+1种的最后一种颜色必须在第i种最后一种颜色的后面,其它颜色任意。总共同拥有多少种排列点的方法。
分析:
如果d[i]表示前i种的排列的数量,那么第i+1种的数量就是d[i]*C(a[1]+a[2]+..a[i+1]-1,a[i+1]-1);预先处理好排列组合数就好了。直接计算。
ps:CF的比赛时间还真是有点烦,话说我一直不明确为什么我看电视能坚持到两点,打CF就不行呢?于是我就边看电视边打CF~哈哈哈哈
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define read freopen("q.in","r",stdin)
#define LL long long
#define maxn 1005
#define mod 1000000007
using namespace std;
int c[maxn][maxn];
int a[maxn];
int main()
{
int i,j,k;
c[1][0]=c[1][1]=1;
for(i=2;i<maxn;i++)
{
c[i][0]=1;
for(j=1;j<=i;j++)c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
}
scanf("%d",&k);
int x,sum=0;
for(i=1;i<=k;i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
LL res=1;
for(i=k;i>1;i--)
{
res=(res*(LL)c[sum-1][a[i]-1])%mod;
sum-=a[i];
}
cout<<res<<endl;
}
Codeforces Round #309 (Div. 2) C的更多相关文章
- 贪心 Codeforces Round #309 (Div. 2) B. Ohana Cleans Up
题目传送门 /* 题意:某几列的数字翻转,使得某些行全为1,求出最多能有几行 想了好久都没有思路,看了代码才知道不用蠢办法,匹配初始相同的行最多能有几对就好了,不必翻转 */ #include < ...
- 找规律 Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks
题目传送门 /* 找规律,水 */ #include <cstdio> #include <iostream> #include <algorithm> #incl ...
- Codeforces Round #309 (Div. 1) C. Love Triangles dfs
C. Love Triangles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/553/pro ...
- Codeforces Round #309 (Div. 1) B. Kyoya and Permutation 构造
B. Kyoya and Permutation Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...
- 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 ...
- Codeforces Round #309 (Div. 2) B. Ohana Cleans Up 字符串水题
B. Ohana Cleans Up Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/554/pr ...
- Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks 字符串水题
A. Kyoya and Photobooks Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...
- 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 ...
- Codeforces Round #309 (Div. 2)
A. Kyoya and Photobooks Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He ha ...
- Codeforces Round #309 (Div. 1) A(组合数学)
题目:http://codeforces.com/contest/553/problem/A 题意:给你k个颜色的球,下面k行代表每个颜色的球有多少个,规定第i种颜色的球的最后一个在第i-1种颜色的球 ...
随机推荐
- 配置Jenkins的slave节点的详细步骤适合windows等其他平台(转)
@ 新建一个slave节点在Jenkins服务器上 1,进入Jenkins的主界面,进入“Manage Jenkins” 页面: 2,点击如下图中的“Manage Nodes”: 3,进入页面后点 ...
- Spring源码解析——如何阅读源码(转)
最近没什么实质性的工作,正好有点时间,就想学学别人的代码.也看过一点源码,算是有了点阅读的经验,于是下定决心看下spring这种大型的项目的源码,学学它的设计思想. 手码不易,转载请注明:xingoo ...
- [zencart教程]zencart外贸建站仿站交流俱乐部
[zencart教程]zencart外贸建站仿站交流俱乐部 1.你想自主一天仿做一个精美的zencart 外贸网站; 2.你想自已自主定制精美的psd 图 zencart模板,并把它变成自定义精美 z ...
- webwervice发布时出错 java.security.PrivilegedActionException
错误信息: 信息: Dynamically creating response wrapper bean Class com.potevio.ws.jaxws.DealReqResponse Exce ...
- linux: /usr/bin/ld: cannot find -lloc
/usr/bin/ld: cannot find -lloc ld链接库的时候没发现loc这个库-lloc本事不是文件名字,要去找这个库就搜索libloc, loc, 不能搜索lloc. /usr1/ ...
- Andorid时间控件和日期控件
- 组件接口(API)设计指南[4]-通知(Notifications)
*返回文件夹阅读其它章节: http://blog.csdn.net/cuibo1123/article/details/39894477 通知(Notifications) 通知是托付协议的还有一半 ...
- freemarker自己定义标签报错(三)
freemarker自己定义标签 1.错误描写叙述 freemarker.core.ParseException: Encountered " " at line 14, colu ...
- 微软Ajax--UpdatePanel控件
今天用做日历显示本月的考勤记录,用到了UpdatePanel控件,才发现对这个控件并不太了解,所以找了点儿资料,整理了一下给大家发上来! 一.UpdatePanel的结构 <asp:Script ...
- Qt调用摄像头(截取并保存图片)
原地址:http://blog.csdn.net/liang19890820/article/details/12782531 Qt如何调用系统摄像设备进行显示.截图.录制? QCamera: ...