原文链接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;
}

  

最新文章

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

热门文章

  1. VUE 多页面配置(一)
  2. Python-数据库 基本SQL语句
  3. C#的winform中控制TextBox中只能输入数字
  4. Confluence 6 从其他备份中恢复数据
  5. Vue.js结合vue-router和webpack编写单页路由项目
  6. Laravel 中通过自定义分页器分页方法实现伪静态分页链接以利于 SEO
  7. Web前端渗透测试技术小结(一)
  8. python(7):sympy模块
  9. java----重载
  10. Java 产生一个大于等于200,小于300的随机数,且是10的整数倍