FWT 入门
2024-10-07 05:18:22
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll maxn = 3e5+5;
const ll mod = 1e9+7; ll n;
ll a[maxn], b[maxn];
void fwt(ll *a)
{
for(ll d=1;d<n;d<<=1)
for(ll m=d<<1,i=0;i<n;i+=m)
for(ll j=0;j<d;j++)
{
ll x=a[i+j],y=a[i+j+d];
a[i+j]=(x+y)%mod,a[i+j+d]=(x-y+mod)%mod;
//xor:a[i+j]=x+y,a[i+j+d]=x-y;
//and:a[i+j]=x+y;
//or:a[i+j+d]=x+y;
}
} ll qw(ll a, ll b){
ll res = 1;
while(b){
if (b&1) res = res*a%mod;
a = a*a%mod;
b >>= 1;
}
return res;
} int main () {
cin >> n; for(ll i = 0; i < n; i++){
scanf("%lld", &a[i]);
}
for(ll i = 0; i < n; i++){
scanf("%lld", &b[i]);
}
fwt(a); fwt(b);
for(ll i = 0; i < n; i++){
if (a[i] != 0){
b[i] = b[i]*qw(a[i], mod-2)%mod;
}
}
fwt(b);
for(ll i = 0; i < n; i++){
b[i] = b[i]*qw(n, mod-2)%mod;
printf("%lld\n", b[i]);
} return 0;
}
最新文章
- 我为NET狂群福利:逆天常用的一些谷歌浏览器插件
- 39个让你受益的HTML5教程
- 如何使用Log4net创建日志及简单扩展
- 每天一个linux命令(37):date命令
- csuoj 1503: 点到圆弧的距离
- Codeforces 451E Devu and Flowers(组合计数)
- redis的info
- test generation和MBIST
- HDU 4648 Magic Pen 6 思路
- 如何在Xilinx ISE中使用TCL提高工作效率
- VS2010项目转化为VS2008项目
- 颜色矩阵 滤镜 ColorMatrix
- Ansible hostvars
- golang从简单的即时聊天来看架构演变
- 关于spring boot中 EmbeddedServletContainerCustomizer
- net core体系-API-1Ocelot-(2)继续深入
- 再谈一次关于Java中的 AIO(异步IO) 与 NIO(非阻塞IO)
- .NetCore Session.Redis (转载)
- 软工第三次作业 -- 结对之AutoCS1.0
- eclipse设置字体、字符编码、快捷键
热门文章
- HDU 2871";Memory Control";(线段树区间和并+set.lower_bound)
- H3C 各类路由默认优先级
- linux内核符号表
- 开源项目使用 appveyor 自动构建
- 51nod 1832 前序后序遍历
- 2018-2-13-win10-uwp-从Type使用构造
- redis scan count的含义/二进制安全问题
- 利用Aspose.cells 将查询出的数据导出为excel,并在浏览器中下载。
- 通过Servlet生成验证码图片(转)
- 从头学pytorch(三) 线性回归