-
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
79 lines (73 loc) · 1.55 KB
/
B_Add_0_or_K.cpp
File metadata and controls
79 lines (73 loc) · 1.55 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
68
69
70
71
72
73
74
75
76
77
78
79
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
#define FOR(i, n) for (int i = 0; i < n; i++)
#define FOR1(i, n) for (int i = 1; i <= n; i++)
#define f(i, j, n) for (int i = j; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RSORT(x) sort(x.rbegin(), x.rend())
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define SUM(x) accumulate(x.begin(), x.end(), 0LL)
#define fm(mp) for (const auto &pair : mp)
// int customGCD(int a, int b) {
// while (b != 0) {
// int temp = b;
// b = a % b;
// a = temp;
// }
// return a;
// }
void solve()
{
ll n,k;
cin >> n>>k;
ll a[n];
ll x;
FOR(i, n)
{
cin >> x;
ll rem = x % (k + 1);
x = x + rem * k;
cout << x << " ";
}
// ll smallest = a[0];
// ll index=0;
// FOR(i, n)
// {
// if(a[i]<smallest){
// smallest= a[i];
// index=i;
// }
// }
// a[index]+=k;
cout << "\n";
return;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
ll t;
cin >> t;
while (t--)
{
solve();
}
return 0;
}