BZOJ1856 [Scoi2010]字符串 数论

原文链接http://www.cnblogs.com/zhouzhendong/p/8084577.html


题目传送门 - BZOJ1856


题意概括

  找出由n个1,m个0组成的字符串,且任意前几个字符中1的个数不能比0的个数少,询问满足要求的字符串个数。 


 

题解

  这位大佬写的好。

http://blog.csdn.net/wzq_qwq/article/details/48706151


 

代码

#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long LL;
const LL mod=20100403;
const int N=2000005;
int n,m;
LL fac[N];
LL Pow(LL x,LL y){
	if (y==0)
		return 1LL;
	LL xx=Pow(x,y/2);
	xx=xx*xx%mod;
	if (y&1LL)
		xx=xx*x%mod;
	return xx;
}
LL Inv(LL x){
	return Pow(x,mod-2);
}
LL C(LL n,LL m){
	return fac[n]*Inv(fac[m])%mod*Inv(fac[n-m])%mod;
}
int main(){
	scanf("%d%d",&n,&m);
	fac[0]=1;
	for (LL i=1;i<=n+m;i++)
		fac[i]=fac[i-1]*i%mod;
	printf("%lld",(C(n+m,m)-C(n+m,m-1)+mod)%mod);
	return 0;
}

  

转载于:https://www.cnblogs.com/zhouzhendong/p/BZOJ1856.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值