# HDU 6129 Just do it （组合数）

## Description

There is a nonnegative integer sequence a1…n of length n. HazelFan wants to do a type of transformation called prefix-XOR, which means a1…n changes into b1…n, where bi equals to the XOR value of a1,…,ai. He will repeat it for m times, please tell him the final sequence.

## Input

The first line contains a positive integer T(1≤T≤5), denoting the number of test cases.

For each test case:

The first line contains two positive integers n,m(1≤n≤2×10^5,1≤m≤10^9).

The second line contains n nonnegative integers a1…n(0≤ai≤2^30−1).

## Output

For each test case:

A single line contains n nonnegative integers, denoting the final sequence.

## Sample Input

2
1 1
1
3 3
1 2 3


## Sample Output

1
1 3 1


## AC 代码

#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+10;
int a[maxn], b[maxn];

int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int n,m;
scanf("%d%d", &n, &m);
memset(b,0,sizeof(b));
for(int i=1; i<=n; i++)
scanf("%d", &a[i]);
for(int i=1; i<n; i++)
{
int x=m+i-2,y=i-1;
if((x&y)==y)
for(int j=i; j<=n; j++)
b[j]^=a[j-i+1];
}
for(int i=1; i<=n; i++)
printf(i!=n?"%d ":"%d\n",b[i]);
}
return 0;
}