Skip to content
GabWiki
Search
K
GitHub
Appearance
GitHub
Menu
Return to top
On this page
Table of Contents for current page
位运算
求
n
的第
k
位数字:
n >> k & 1
获取
n
二进制中最低位的
1
(例如
n
=
110100
(
2
)
, 那么
l
o
w
b
i
t
(
n
)
=
100
(
2
)
):
lowbit(n) = n & -n
lowbit(n) = n & (n ^ (n-1))
异或运算
交换律:
p
⊕
q
=
q
⊕
p
结合律:
p
⊕
(
q
⊕
r
)
=
(
p
⊕
q
)
⊕
r
恒等律:
p
⊕
0
=
p
归零律:
p
⊕
p
=
0
自反性:
p
⊕
q
⊕
q
=
p
⊕
0
=
p