编程介的小学生 2019-04-28 00:50 采纳率: 20.5%
浏览 98

数组的位置的变幻的算法,利用C语言的程序的设计的思想去解决的方式

Problem Description
Mike has got a huge array b, and he is told that the array is encrypted.

The array is encrypted as follows.

Let ai(0≤i<n) be the i-th number of this original array.

Let bi(0≤i<n) be the i-th number of this encrypted array.

Let n be a power of 2, which means n=2k.

The bi is calculated as following.

bi=∑0≤j<nf((i or j) xor i)aj

f(x) means, if the number of 1 in the binary of x is even, it will return 1, otherwise 0.

Mike want to inverse the procedure of encryption.

Please help him recover the array a with the array b.

Input
The first line contains an integer T(T≤5), denoting the number of the test cases.

For each test case, the first line contains an integer k(0≤k≤20),
The next line contains n=2k integers, which are bi respectively.

It is guaranteed that, ai is an integer and 0≤ai≤109.

Output
For each test case, output ''Case #t:'' to represent this is the t-th case. And then output the array a.

Sample Input
2
0
233
2
5 3 4 10

Sample Output
Case #1: 233
Case #2: 1 2 3 4

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog