问题
enter image description here
“⊕” is the bitwise XOR operation.
I think Karatsuba’s algorithm may be used to solve the problem, but when I try to use XOR instead of "+" in the Karatsuba’s algorithm, it is tough to get the sub-problem.
回答1:
The convolution theorem gives you
F(C) = F(A) . F(B)
where F
is a Fourier-related transform, in this case the Hadamard transform, and .
is point-wise multiplication. Using the fast Walsh–Hadamard transform, you can compute F(A)
, F(B)
, and finally C
(using the inverse), in O(n log n)
operations. The point-wise multiplication is simply O(n)
.
来源:https://stackoverflow.com/questions/53591757/how-to-calculate-xor-dyadic-convolution-with-time-complexity-on-log-n