首页 技术 正文
技术 2022年11月23日
0 收藏 362 点赞 4,884 浏览 766 个字

题意:

就是给出总共同拥有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;}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,994
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,507
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,350
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,135
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,768
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,845