# Codeforces Global Round 10 B. Omkar and Infinity Clock

Being stuck at home, Ray became extremely bored. To pass time, he asks Lord Omkar to use his time bending power: Infinity Clock! However, Lord Omkar will only listen to mortals who can solve the following problem:

You are given an array 𝑎 of 𝑛 integers. You are also given an integer 𝑘. Lord Omkar wants you to do 𝑘 operations with this array.

Define one operation as the following:

Set 𝑑 to be the maximum value of your array.
For every 𝑖 from 1 to 𝑛, replace 𝑎𝑖 with 𝑑−𝑎𝑖.
The goal is to predict the contents in the array after 𝑘 operations. Please help Ray determine what the final sequence will look like!

Input
Each test contains multiple test cases. The first line contains the number of cases 𝑡 (1≤𝑡≤100). Description of the test cases follows.

The first line of each test case contains two integers 𝑛 and 𝑘 (1≤𝑛≤2⋅105,1≤𝑘≤1018) – the length of your array and the number of operations to perform.

The second line of each test case contains 𝑛 integers 𝑎1,𝑎2,…,𝑎𝑛 (−109≤𝑎𝑖≤109) – the initial contents of your array.

It is guaranteed that the sum of 𝑛 over all test cases does not exceed 2⋅105.

Output
For each case, print the final version of array 𝑎 after 𝑘 operations described above.

Example
inputCopy
3
2 1
-199 192
5 19
5 -1 4 2 0
1 2
69
outputCopy
391 0
0 6 1 3 5
0
Note
In the first test case the array changes as follows:

Initially, the array is [−199,192]. 𝑑=192.

After the operation, the array becomes [𝑑−(−199),𝑑−192]=[391,0].

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <unordered_map>
#include <bitset>

using namespace std;

typedef long long ll;
const int maxn = 2e5 + 7;
const int mod = 998244353;

int a[maxn];

int main() {
int T;scanf("%d",&T);
while(T--) {
ll n,k;scanf("%lld%lld",&n,&k);
int mx = -1e9;
for(int i = 1;i <= n;i++) {
scanf("%d",&a[i]);
mx = max(mx,a[i]);
}
k--;
for(int i = 1;i <= n;i++) {
a[i] = mx - a[i];
}
mx = -1e9;
for(int i = 1;i <= n;i++) {
mx = max(mx,a[i]);
}
for(int i = 1;i <= n;i++) {
if(k & 1) {
a[i] = mx - a[i];
}
printf("%d ",a[i]);
}
printf("\n");
}
return 0;
}


08-17 985
08-17 361