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种颜色的球 ...
随机推荐
- 基于visual Studio2013解决C语言竞赛题之0705矩阵转置
题目 解决代码及点评 /* 5. 写一函数,将一个3×3的矩阵转置. */ #include <stdio.h> #include <stdlib.h> void mai ...
- UVA 10581 - Partitioning for fun and profit(数论递推)
10581 - Partitioning for fun and profit 题目链接 题意:给定m, n,表示分配给n个格子,分配m个数字进去,每一个格子最少1,而且序列要是递增的,问第k个字典序 ...
- db2常用命令(详解)大全
近一年来在项目开发中使用到了IBM的DB2 9.1的数据库产品,跟Oracle相比一些命令有很大的区别,而它最大的功能是支持 xml存储.检索机制,通过XPath进行解析操作,使开发人员免于 ...
- PHP - 遍历文件夹下的所有文件名
/** * * 函数名:myreaddir($dir) * 作用:读取目录所有的文件名 * 参数:$dir 目录地址 * 返回值:文件名数组 * * */ function myreaddir($di ...
- 64位与32位编程的数据类型区别(C/C++)
C/C++仅仅定义了这些基本数据类型之间的关系,并没有定义严格定义它们的字长.在不同的平台上,根据编译器不同的实现,它们的字长如下表所示: 数据类型 LP64 ILP64 LLP64 ILP32 LP ...
- Shell脚本笔记
如何查询文件里的某个字符串? grep “字符串” 文件 例:grep "abc" tmp.txt 如何将查询出来的内容赋给变量? str=$(grep "abc ...
- 解决Charles Response 中文乱码
Response中文乱码:在Info.plist 中 的vmoption 添加-Dfile.encoding=UTF-8 info.plist路径 应用程序->Charles.app->显 ...
- 【Android开源项目分析】android轻量级开源缓存框架——ASimpleCache(ACache)源代码分析
转载请注明出处:http://blog.csdn.net/zhoubin1992/article/details/46379055 ASimpleCache框架源代码链接 https://github ...
- word2vec 中的数学原理具体解释(一)文件夹和前言
word2vec 是 Google 于 2013 年开源推出的一个用于获取 word vector 的工具包.它简单.高效.因此引起了非常多人的关注. 因为 word2vec 的作者 Tomas ...
- 在 Visual Studio 2010 中开发和部署 Windows Azure 应用程序
原文 在 Visual Studio 2010 中开发和部署 Windows Azure 应用程序 在 Visual Studio 2010 中开发和部署 Windows Azure 应用程序 Jim ...