1 Star 0 Fork 0

ShawnBox / OI

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
chest.cpp 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
ShawnBox 提交于 2018-07-25 09:15 . 初始化
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int n;
int a[20],b[20];
ll fac[200];
void Init(){
fac[0]=1;
for(int i=1;i<=150;i++)
fac[i]=(fac[i-1]*i)%MOD;
}
ll ksm(ll x,int y){
ll cnt=1;
while(y){
if(y&1)
cnt=(cnt*x)%MOD;
x=(x*x)%MOD;
y>>=1ll;
}
return cnt;
}
ll inv(ll x){
return ksm(x,MOD-2);
}
int main(){
freopen("chest.in","r",stdin);
freopen("chest.out","w",stdout);
Init();
while(~scanf("%d",&n)){
memset(a,0,sizeof a);
ll tot=0;
for(int i=1;i<=n;i++){
scanf("%d",&b[i]);
a[b[i]]++;
tot+=b[i];
}
tot=fac[tot];
for(int i=1;i<=n;i++)
tot=((tot*inv(fac[b[i]]))%MOD+MOD)%MOD;
for(int i=1;i<=12;i++)
if(a[i]!=0)
tot=((tot*inv(fac[a[i]]))%MOD+MOD)%MOD;
tot=(tot+MOD)%MOD;
printf("%lld\n",tot);
}
fclose(stdin);
fclose(stdout);
}
C++
1
https://gitee.com/ShawnBox/OI.git
git@gitee.com:ShawnBox/OI.git
ShawnBox
OI
OI
master

搜索帮助