添加内容

This commit is contained in:
ember 2025-09-06 01:49:57 +08:00
parent 8d10c94516
commit 749e3c1146

View File

@ -27,6 +27,7 @@ math: true
| `x & 1` | 判断奇偶性:真为奇,假为偶 |
| `(n > 0) && ((n & (n - 1)) == 0)` | 判断n是否为2的幂。因为2的幂的二进制只有一个1用n & (n-1)可以直接把它唯一的1去掉变成0。
| `n & ((1 << k) - 1)` | 等价于 `n % (1 << k)`,即`n`对$2^k$取模 |
| `a ^= b; b ^= a; a ^= b` | 交换a和b的值 |
统计二进制数中1的个数
```cpp