-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB_Add_0_or_K.cpp
More file actions
67 lines (54 loc) · 1.25 KB
/
B_Add_0_or_K.cpp
File metadata and controls
67 lines (54 loc) · 1.25 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;
typedef long long ll;
ll mod = 998244353;
ll pow_2(ll a, ll b) {
ll res = 1;
while(b){
if(b&1) res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res;
}
void solve() {
ll n,r,b,k;
cin >> n>>k;
vector<ll> ans(n);
for(int i=0;i<n;i++){
cin>>ans[i];
}
if(k%2==1){
for(int i=0;i<n;i++){
if(ans[i]%2==1)ans[i]+=k;
}
}
else if(k==2){
for(int i=0;i<n;i++){
if(ans[i]%3==0)continue;
if(ans[i]%3==1)ans[i]+=2;
else if (ans[i]%3==2)ans[i]+=4;
}
}
else{
int fuck=k-1;
for(int i=0;i<n;i++){
ans[i]+=(fuck-(ans[i]%fuck))*k;
}
}
for(int i=0;i<n;i++){
cout<<ans[i]<<" ";
}
cout<<endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--) solve();
return 0;
}