二项式反演
\[f(n)=\sum_{i=0}^n{n\choose i}g(i) \iff g(n)=\sum_{i=0}^n(-1)^{(n-i)}{n\choose i} f(i)
\]
证明如下:
\[g(n)=\sum_{i=0}^n(-1)^{n-i}{n \choose i} \sum_{j=0}^i {i\choose j}g(j)\\
g(n)=\sum_{i=0}^n \sum_{j=0}^i (-1)^{n-i}{n \choose i} {i\choose j}g(j)\\
g(n)=\sum_{j=0}^n \sum_{i=j}^n (-1)^{n-i}{n \choose i} {i\choose j}g(j)\\
\]
\[{i \choose j}{j \choose k}=\frac{i!j!}{j!(i-j)!k!(j-k)!}\\
=\frac{i!(i-k)!}{(i-j)!(i-k)!k!(j-k)!}\\
=\frac{i!}{k!(i-k)!}\frac{(i-k)!}{(i-j)!(j-k)!}\\
=\frac{i!}{k!(i-k)!}\frac{(i-k)!}{(j-k)!((i-k)-(j-k))!}\\
={i \choose k}{i-k \choose j-k}
\]
\[g(n)=\sum_{j=0}^n \sum_{i=j}^n (-1)^{n-i}{n \choose j} {n-j\choose i-j}g(j)\\
g(n)=\sum_{j=0}^n \sum_{i=0}^{n-j} (-1)^{n-i-j}{n-j\choose i} {n \choose j} g(j)\\
\]
\[\sum_{i=0}^{n-j} (-1)^{n-i-j}{n-j\choose i}1^{i}\\
(1-1)^{n-j}
\]
\[g(n)=\sum_{j=0}^n (1-1)^{n-j}{n \choose j} g(j)\\
g(n)=g(n)\\
\]