简单的容斥原理可以通过画文氏图来理解:
\( \left | S_1\cup S_2 \right |=\left | S_1 \right |+\left | S_2 \right |-\left | S_1\cap S_2 \right | \)
\( \left | S_1\cup S_2 \cup S_3 \right |=\left | S_1 \right |+\left | S_2 \right |+\left | S_3 \right |-\left | S_1\cap S_2 \right |-\left | S_1\cap S_3 \right |-\left | S_2\cap S_3 \right |-\left | S_1\cap S_2 \cap S_3 \right | \)
可得:
\[
\left |S_1 \cup S_2 \cup ...S_n \right |=\sum_{i=1}^{n}((-1)^{n-1}*\sum_{j=1}^{C_{n}^{i}}\left |S_{x1} \cap S_{x2} \cap...S_{xi} \right|)
\]
后面那个\( \sum \)里是\( i \) 个元素的一种组合