#P6097. 【模板】子集卷积

    ID: 6874 远端评测题 5000ms 1024MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>O2优化快速沃尔什变换 FWT快速莫比乌斯变换 FMT集合幂级数,子集卷积

【模板】子集卷积

Background

This is a template problem.

Problem Description

Given two sequences of length 2n2^n, a0,a1,,a2n1a_0,a_1,\cdots,a_{2^n-1} and b0,b1,,b2n1b_0,b_1,\cdots,b_{2^n-1}, you need to compute a sequence c0,c1,,c2n1c_0,c_1,\cdots,c_{2^n-1}, where ckc_k satisfies:

$$c_k=\sum_{\substack{{i \& j=0}\\{i~\mid~ j=k}}} a_i b_j$$

Here,   ~\mid~ denotes bitwise OR, and &\& denotes bitwise AND.

The answer should be taken modulo 109+910^9+9.

Input Format

The first line contains a positive integer nn, representing the size of the set.

The second line contains 2n2^n integers, describing aa.

The third line contains 2n2^n integers, describing bb.

Output Format

Output one line with 2n2^n integers, representing cc.

2
1 0 2 1
2 0 2 1
2 0 6 3

Hint

For all testdata, 1n201\le n\le 20, 0ai,bi<109+90\le a_i,b_i< 10^9+9.

Translated by ChatGPT 5