CF1034E.Little C Loves 3 III

NOI/NOI+/CTSC

通过率:0%

时间限制:1.00s

内存限制:64MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Little C loves number «3» very much. He loves all things about it.

Now he is interested in the following problem:

There are two arrays of 2n2^n intergers a0,a1,...,a2n−1a_0,a_1,...,a_{2^n-1} and b0,b1,...,b2n−1b_0,b_1,...,b_{2^n-1}.

The task is for each i(0≤i≤2n−1)i (0 \leq i \leq 2^n-1), to calculate ci=∑aj⋅bkc_i=\sum a_j \cdot b_k (j∣k=ij|k=i and j&k=0j\&k=0, where "∣|" denotes bitwise or operation and "&\&" denotes bitwise and operation).

It's amazing that it can be proved that there are exactly 3n3^n triples (i,j,k)(i,j,k), such that j∣k=ij|k=i, j&k=0j\&k=0 and 0≤i,j,k≤2n−10 \leq i,j,k \leq 2^n-1. So Little C wants to solve this excellent problem (because it's well related to 33) excellently.

Help him calculate all cic_i. Little C loves 33 very much, so he only want to know each ci&3c_i \& 3.

小 C 非常喜欢数字「3」,他对所有与之相关的事物都情有独钟。

现在他感兴趣的问题如下:

给定两个长度为 2n2^n 的整数数组:a0,a1,…,a2n−1a_0, a_1, \dots, a_{2^n-1} 和 b0,b1,…,b2n−1b_0, b_1, \dots, b_{2^n-1}。

任务是:对每个 ii(其中 0≤i≤2n−10 \leq i \leq 2^n-1),计算

ci=∑aj⋅bk,c_i = \sum a_j \cdot b_k,

其中求和遍历所有满足 j∣k=ij|k=i 且 j&k=0j\&k=0 的下标对 (j,k)(j,k);这里 "∣|" 表示按位或运算,"&\&" 表示按位与运算。

令人惊奇的是,可以证明:满足 j∣k=ij|k=i、j&k=0j\&k=0 且 0≤i,j,k≤2n−10 \leq i,j,k \leq 2^n-1 的三元组 (i,j,k)(i,j,k) 恰好有 3n3^n 个。因此,小 C 希望出色地解决这个卓越的问题(因为它与数字 33 密切相关)。

请帮助他计算出所有的 cic_i。小 C 非常喜爱数字 33,所以他只关心每个 ci&3c_i \& 3 的值。

输入格式

The first line contains one integer n(0≤n≤21)n (0 \leq n \leq 21).

The second line contains 2n2^n integers in [0,3][0,3] without spaces — the ii-th of them is ai−1a_{i-1}.

The third line contains 2n2^n integers in [0,3][0,3] without spaces — the ii-th of them is bi−1b_{i-1}.

第一行包含一个整数 n(0≤n≤21)n (0 \leq n \leq 21)。

第二行包含 2n2^n 个在 [0,3][0,3] 范围内的整数,中间无空格——其中第 ii 个数为 ai−1a_{i-1}。

第三行包含 2n2^n 个在 [0,3][0,3] 范围内的整数,中间无空格——其中第 ii 个数为 bi−1b_{i-1}。

输出格式

Print one line contains 2n2^n integers in [0,3][0,3] without spaces — the ii-th of them is ci−1&3c_{i-1}\&3. (It's obvious that ci&3c_{i}\&3 is in [0,3][0,3]).

输出一行,包含 2n2^n 个在 [0,3][0,3] 范围内的整数,中间不加空格——其中第 ii 个数为 ci−1&3c_{i-1}\&3。(显然 ci&3c_{i}\&3 的值在 [0,3][0,3] 范围内)

输入输出样例

  • 输入#1

    1
    11
    11

    输出#1

    12
  • 输入#2

    2
    0123
    3210

    输出#2

    0322

输入解题思路,AI测评打分。不知道怎么写?

首页