BZOJ1856 [Scoi2010]字符串 数论
2024-10-17 23:05:17
原文链接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;
}
最新文章
- stanford NLP学习笔记3:最小编辑距离(Minimum Edit Distance)
- PetaPoco dynamic
- 编解码-java序列化
- Qt 学习资料
- 动态LOV语句、向具有LOV的ITEM赋值时报FRM-40212需要验证错误
- VS2013配置WTL90_4140_Final
- C#调用sap接口及返回数据到sap
- CLR via C# 内存管理读书记
- 对于AttributeError: &#39;Flask&#39; object has no attribute &#39;cli&#39;的解决办法
- linux安装bind with DLZ <;NIOT>;
- 环境搭建-VMware安装系统
- zabbix监控redis
- [leetcode-565-Array Nesting]
- iOS知识点、面试题 之三
- Spring 4.x (三)
- [HNOI2012]双十字
- Spring Cloud Alibaba基础教程:Nacos的数据持久化
- 学习 Spring (八) 注解之 Bean 的定义及作用域
- BZOJ3286 Fibonacci矩阵 矩阵 快速幂 卡常
- win7系统开机后电脑桌面背景变黑的解决方法