-
Notifications
You must be signed in to change notification settings - Fork 0
/
B.cpp
49 lines (48 loc) · 984 Bytes
/
B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
int main()
{
fastio;
long long t,n,k,i,mx;
static long long ara[200003],arb[200003];
cin>>t;
while(t--)
{
cin>>n>>k;
for(i=0;i<n;i++)
{
cin>>ara[i];
if(i==0)
mx=ara[i];
else if(ara[i]>mx)
mx=ara[i];
}
for(i=0;i<n;i++)
{
ara[i]=mx-ara[i];
}
for(i=0;i<n;i++)
{
if(i==0)
mx=ara[i];
else if(ara[i]>mx)
mx=ara[i];
}
for(i=0;i<n;i++)
arb[i]=mx-ara[i];
if(k%2==1)
{
for(i=0;i<n;i++)
cout<<ara[i]<<" ";
cout<<"\n";
}
else
{
for(i=0;i<n;i++)
cout<<arb[i]<<" ";
cout<<"\n";
}
}
return 0;
}