Skip to content

Commit edc1b9f

Browse files
committed
upd
1 parent 9124e40 commit edc1b9f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

leetcode/weekly/477/d/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ $$
4444
\sum_{S \subseteq \textit{or}} (-1)^{|\complement_{\textit{or}}S|}2^{f[S]}
4545
$$
4646

47-
其中 $\complement_{\textit{or}}S$ 表示 $S$ 关于 $\textit{or}$ 的补集,$|\complement_{\textit{or}}S|$ 即这个补集的大小(元素个数),说人话就是:
47+
其中 $\complement_{\textit{or}}S$ 表示 $S$ 关于 $\textit{or}$ 的补集,$|\complement_{\textit{or}}S|$ 即这个补集的大小(元素个数)。
48+
49+
通俗地说:
4850

4951
- 如果 $S$ 与 $\textit{or}$ 相差偶数个数,那么加上 $2^{f[S]}$。
5052
- 如果 $S$ 与 $\textit{or}$ 相差奇数个数,那么减去 $2^{f[S]}$。
@@ -102,9 +104,9 @@ class Solution:
102104
while True:
103105
p2 = pow2[f[sub]]
104106
ans -= -p2 if (or_all ^ sub).bit_count() % 2 else p2
105-
sub = (sub - 1) & or_all
106-
if sub == or_all:
107+
if sub == 0:
107108
break
109+
sub = (sub - 1) & or_all
108110
return ans % MOD
109111
```
110112

0 commit comments

Comments
 (0)