QOJ.ac

QOJ

Type: Editorial

Status: Open

Posted by: jiangly

Posted at: 2025-12-12 23:49:39

Last updated: 2025-12-12 23:49:44

Back to Problem

题解

我们对每个 $i=0,\ldots,44$,求出异或的 popcount 是 $i$ 的方案数。

假设秩为 $r$,基以外的方案数就是 $2^{n-r}$,然后我们对 $r$ 的大小分类讨论。

如果 $r\le 22$,那么我们直接枚举空间中的数,时间复杂度 $O(2^r)$。

如果 $r>22$,我们求出正交补,也就是空间中的数 $x$ 满足 $x^Tv_i=0(i=1,\ldots,44-r)$。也就是说,我们对每个 $x$ 要算的系数是 $\frac{1+(-1)^{x^T v}}{2}$。我们把式子直接展开,就只需要对 $2^{44-r}$ 个 $v$ 计算每种 $popcount(x)$ 的 $(-1)^{x^Tv}$ 的和。这个和只和 $popcount(v)$ 有关:假设 $popcount(v)=c$,那么 $popcount(x)$ 的生成函数就是 $\left(1-x\right)^c(1+x)^{44-c}$。时间复杂度 $O(44^3+2^{44-r})$。

Comments

No comments yet.