题意:

求含有A个"RR",B个"RB",C个"BB",D个"BR"的字符串个数。

解法:

首先考虑"BR"与"RB",我们可以首先"B","R"相间来排列进而满足B,D的限制。

这样,我们只需要考虑将"BB"和"RR"塞入初始得到的串即可,考虑隔板法。

PS:这题数据"0 0 0 0"有毒。

 #include <iostream>
#include <cstdio>
#include <cstring> #define LL long long
#define P 1000000007LL
#define N 100010 using namespace std; int a,b,c,d;
LL fac[N*]; LL qpow(LL x,int n)
{
LL ans=;
for(;n;n>>=,x=x*x%P)
if(n&) ans=ans*x%P;
return ans;
} LL C(int n,int m)
{
if(m==) return 1LL;
return fac[n]*qpow(fac[n-m],P-)%P*qpow(fac[m],P-)%P;
} int main()
{
fac[]=;
for(int i=;i<*N;i++) fac[i] = fac[i-]*(LL)i%P;
while(~scanf("%d%d%d%d",&a,&b,&c,&d))
{
if(b== && d==)
{
if(a!= && c!=) puts("");
else if(a!= || c!=) puts("");
else puts("");
continue;
}
LL ans;
if(b==d)
{
ans = C(c+b-,b-)*C(a+b,b)%P;
ans += C(c+b,b)*C(a+b-,b-)%P;
if(ans>=P) ans-=P;
cout << ans << endl;
}
else if(b==d+ || d==b+)
{
b = max(b,d);
ans = C(b+c-,b-)*C(b+a-,b-)%P;
cout << ans << endl;
}
else puts("");
}
return ;
}

最新文章

  1. android 创建数组
  2. 比较器:Compare接口与Comparator接口区别与理解
  3. Android事件分发机制理解
  4. HttpHandler过滤请求..
  5. NBU官方Doc網址https://www.veritas.com/support/en_US/article.DOC5332
  6. C语言连接SQLSERVER数据库
  7. CodeForces#275--DIV 2--B(BinarySearch)(!!)
  8. 盘点mysql中容易被我们误会的地方
  9. linux进程用户内存空间和内核空间
  10. input file类型,文件类型的限制
  11. oracle安装后登录
  12. golang的推荐的orm库
  13. 重装linux后
  14. JavaScript之引用类型讲解
  15. 项目图片上传存储的目录部分代码思路Calendar类获取年月日
  16. 屏蔽全部统计代码(51.la cnzz 百度统计 谷歌分析师adsense、屏蔽淘宝客广告代码)的方法
  17. 简单说说Markdown语法
  18. POJ2762 Going from u to v or from v to u? 强连通分量缩点+拓扑排序
  19. 高阶函数 map、reduce、filter、sort 函数计算
  20. Ubuntu 16.04 编译OpenCV 问题解决stdlib.h: No such file or directory

热门文章

  1. Allegro PCB中封装焊盘替换操作详解
  2. Terminal emulator
  3. iOS 图像处理-剪裁图像
  4. crazyflie2.0 RCC时钟知识
  5. 使用 Visual Studio Code 运行 C# 及 Java 程序
  6. android开发基础知识了解
  7. MapReduce源代码分析之LocatedFileStatusFetcher
  8. ABAP DEMO-2018
  9. 2018年东北农业大学春季校赛 D wyh的迷宫 【BFS】
  10. APP上线审核注意事项