标签:class xor 快速 else int 变换 code += inline
inline void FWT_or(ll *f, ll x = 1) {
for (int p = 2, k = 1;p <= n; p <<= 1, k <<= 1)
for (int i = 0;i < n; i += p)
for (int j = 0;j < k; j++)
if (~x) f[i+j+k] = (f[i+j+k] + f[i+j]) % P;
else f[i+j+k] = (f[i+j+k] - f[i+j] + P) % P;
}
inline void FWT_and(ll *f, ll x = 1) {
for (int p = 2, k = 1;p <= n; p <<= 1, k <<= 1)
for (int i = 0;i < n; i += p)
for (int j = 0;j < k; j++)
if (~x) f[i+j] = (f[i+j+k] + f[i+j]) % P;
else f[i+j] = (f[i+j] - f[i+j+k] + P) % P;
}
inline void FWT_xor(ll *f, ll opt = 1) {
for (int p = 2, k = 1;p <= n; p <<= 1, k <<= 1)
for (int i = 0;i < n; i += p)
for (int j = 0;j < k; j++) {
ll x = f[i+j], y = f[i+j+k];
f[i+j] = (x + y) % P;
f[i+j+k] = (x + P - y) % P;
if (opt==-1) f[i+j] = f[i+j] * inv2 % P, f[i+j+k] = f[i+j+k] * inv2 % P;
}
}
标签:class xor 快速 else int 变换 code += inline
原文地址:https://www.cnblogs.com/Hs-black/p/12271681.html