题解 1 的思路
#include <iostream>
using namespace std;
int a[100005], b[100005];
int main(int argc, const char * argv[]) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
// insert code here...
int T;
cin >> T;
while (T--) {
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
b[0] ^= a[i];
}
for (int i = 1; i <= n; i++) {
b[i] = b[0] ^ a[i];
}
if (k % 2 == 0) {
for (int i = 1; i <= n; i++) {
cout << a[i] << ' ';
}
} else {
for (int i = 1; i <= n; i++) {
cout << b[i] << ' ';
}
}
cout << endl;
}
return 0;
}