Question source
Title
To an array arr (maximum 2E5 ), is given an operation determined arr each prefix and XOR, as a new arr .
Operate the maximum number of 1E9 , last asked arr array is valid
idea
1. M is so big, instinctively want to find the pattern ( I also found the wrong in the game... )
2. After the game, I played the table again and found the rule of 1-2-4-8 ( you will know when you hit the table to 8 )
3. Binary enumeration with 1e9 is enough for the law ( here is very similar to fast exponentiation )
Pay attention to details when writing, easy to cross the boundary (code is as follows)
AC code
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <cstdio>
#include <math.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define sc(x) scanf("%d",&x);
#define pr(x) cout << x << endl;
#define bug(x) cout << #x << " = " << x << endl;
#define ppr(x,y) cout << "(" << x << "," << y << ")" << endl;
#define mem(arr,x) memset(arr,x,sizeof arr);
#define clr(arr) mem(arr,0);
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int a[maxn];
int n,m;
void F(int x){ //m = x 时的变换
for(int i = x + 1; i <= n ; ++i)
a[i] ^= a[i - x];
}
void _Bit(){ //用二进制枚举把m 分解成二进制乘积的变换
int x = 1;
while(m){
if(m & 1){
F(x);
}
x *= 2;
m >>= 1;
}
}
int main(){
ios::sync_with_stdio(false);
int T;
sc(T)
while(T--){
scanf("%d%d",&n,&m);
for(int i = 1 ; i <= n ; i++) scanf("%d",a + i);
_Bit();
for(int i = 1; i <= n ; i++) printf("%d%c",a[i],i == n ? '\n' : ' ');
}
}