Wannafly挑战赛17 B
题解
大概就是求证这个
\[\sum_i^nC_{n}^i*C_n^i = C_{2n}^n
\]
证明:
\[(1+x)^{2n} = [C(0,n)+C(1,n)*x+...+C(n,n)*x^n]*[[C(0,n)+C(1,n)*x+...+C(n,n)*x^n]]
\]
\[=...+[C(0,n)*C(n,n)+C(n-1,n)+...+C(n,n)*C(0,n)]x^n+...
\]
也就是说,在\((1+x)^{2n}\)的展开式中,\(x^n\)的系数是
\[\sum_k^nC(k,n)*C(n-k) = \sum_k^nC(k,n)^2
\]
以上,我们证明了范德蒙德卷积
根据二项式定理
\[(1+x)^{2n}=\sum_k^{2n}[C(k,2n)]*x^k$$即$x^k$的系数为C(n,2n),由此可得$\sum_k^nC(k,n)^2 = C(n,2n)$
###代码
```c++
#include<cstdio>
#include<algorithm>
#define LL long long
#define mod 998244353
LL inv(LL x,int y) {
LL ret = 1;
for(;y;y >>= 1,x = x * x % mod)
if(y & 1) ret = ret * x % mod;
return ret;
}
const int maxn = 1000007;
LL jc[maxn * 2];
LL C(int a,int b) {
return ((((jc[a] * inv(jc[b],mod - 2)% mod) + mod) % mod)
* inv(jc[a - b],mod - 2) + mod) % mod;
}
int main() {
jc[0] = jc[1] = 1;
int n;
scanf("%d",&n);
for(int i = 2;i <= 2 * n;++ i)
jc[i] = jc[i - 1] * i % mod;
LL ans = 0;
for(int i = 1;i <= n;++ i)
ans = (ans + C(2 * i,i)) % mod;
printf("%lld\n",ans);
return 0;
}
```\]