题意:n个数进行m次前缀和异或和后的情况,其中$n,m(1\leq n\leq2\times10^5,1\leq m\leq10^9)$。
思路:看到m这么大,肯定要分解m的,又是异或和,二进制分解后,发现第i的位置上值为与i相距 [m分解后的各个值]位置上的异或,复杂度O(nlogm)。
/** @Date : 2017-08-18 16:10:51
* @FileName: 1010 规律.cpp
* @Platform: Windows
* @Author : Lweleth (SoungEarlf@gmail.com)
* @Link : https://github.com/
* @Version : $Id$
*/
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 5e5+20;
const double eps = 1e-8;
LL a[N];
int main()
{
int T;
cin >> T;
while(T--)
{
LL n, m;
scanf("%lld%lld", &n, &m);
for(int i = 0; i < n; i++)
scanf("%lld", a + i);
for(int i = 0; i < 32; i++)
{
if((m & (1LL << i)) == 0)//注意优先级...
continue;
for(int j = 0; j < n; j++)
{
if(j - (1 << i) >= 0)
a[j] ^= a[j - (1 << i)];
//printf("%lld%s", a[j], j==n-1?"\n":" ");
}
}
for(int i = 0; i < n; i++)
printf("%lld%s", a[i], i==n-1?"\n":" ");
}
return 0;
}