http://www.lydsy.com/JudgeOnline/problem.php?id=1856
题意:把n个1和m个0组成字符串,要求在组成的字符串中,任意的前k个字符1的个数不能少于0的个数。求字符串共有多少个。(1<=m<=n<=1000000)
#include <bits/stdc++.h> using namespace std; const int M=20100403; typedef long long ll; int mpow(int a, int b) { int x=1; for(; b; b>>=1, a=(ll)a*a%M) if(b&1) x=(ll)x*a%M; return x; } int fac(int n) { int x=1; for(int i=2; i<=n; ++i) x=(ll)x*i%M; return x; } int main() { int n, m; cin >> n >> m; cout << (ll)(n+1-m)*fac(n+m)%M*mpow((ll)fac(n+1)*fac(m)%M, M-2)%M << endl; return 0; }
好题啊= =
将狼踩尽神犇写的题解太赞了= =:http://www.cnblogs.com/jianglangcaijin/p/3443689.html
我来简单说一下....
首先总方案数有$\binom{n+m}{n}$,然后有$\binom{n+m}{n+1}$是不合法的= =然后就行辣= =(送个配图= =
原文:http://www.cnblogs.com/iwtwiioi/p/4348743.html