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 2n intergers a0,a1,...,a2n−1 and b0,b1,...,b2n−1.
The task is for each i(0≤i≤2n−1), to calculate ci=∑aj⋅bk (j∣k=i and j&k=0, where "∣" denotes bitwise or operation and "&" denotes bitwise and operation).
It's amazing that it can be proved that there are exactly 3n triples (i,j,k), such that j∣k=i, j&k=0 and 0≤i,j,k≤2n−1. So Little C wants to solve this excellent problem (because it's well related to 3) excellently.
Help him calculate all ci. Little C loves 3 very much, so he only want to know each ci&3.
小 C 非常喜欢数字「3」,他对所有与之相关的事物都情有独钟。
现在他感兴趣的问题如下:
给定两个长度为 2n 的整数数组:a0,a1,…,a2n−1 和 b0,b1,…,b2n−1。
任务是:对每个 i(其中 0≤i≤2n−1),计算
ci=∑aj⋅bk,
其中求和遍历所有满足 j∣k=i 且 j&k=0 的下标对 (j,k);这里 "∣" 表示按位或运算,"&" 表示按位与运算。
令人惊奇的是,可以证明:满足 j∣k=i、j&k=0 且 0≤i,j,k≤2n−1 的三元组 (i,j,k) 恰好有 3n 个。因此,小 C 希望出色地解决这个卓越的问题(因为它与数字 3 密切相关)。
请帮助他计算出所有的 ci。小 C 非常喜爱数字 3,所以他只关心每个 ci&3 的值。
输入格式
The first line contains one integer n(0≤n≤21).
The second line contains 2n integers in [0,3] without spaces — the i-th of them is ai−1.
The third line contains 2n integers in [0,3] without spaces — the i-th of them is bi−1.
第一行包含一个整数 n(0≤n≤21)。
第二行包含 2n 个在 [0,3] 范围内的整数,中间无空格——其中第 i 个数为 ai−1。
第三行包含 2n 个在 [0,3] 范围内的整数,中间无空格——其中第 i 个数为 bi−1。
输出格式
Print one line contains 2n integers in [0,3] without spaces — the i-th of them is ci−1&3. (It's obvious that ci&3 is in [0,3]).
输出一行,包含 2n 个在 [0,3] 范围内的整数,中间不加空格——其中第 i 个数为 ci−1&3。(显然 ci&3 的值在 [0,3] 范围内)
输入输出样例
输入#1
1 11 11
输出#1
12
输入#2
2 0123 3210
输出#2
0322
输入解题思路,AI测评打分。不知道怎么写?