-
Notifications
You must be signed in to change notification settings - Fork 0
/
arithmetic.cpp
60 lines (51 loc) · 1.22 KB
/
arithmetic.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
50
51
52
53
54
55
56
57
58
59
60
//
// Created by Tony on 12/4/2021.
//
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define f first
#define s second
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("","r",stdin);
// freopen("","w",stdout);
int n;
cin >> n;
while (n--) {
ll terms;
ll sum;
cin >> terms >> sum;
if (terms % 2 == 1)
{
if (sum%terms != 0)
cout << "IMPOSSIBLE" << endl;
else
{
for (int i = 0; i < terms; i++) {
cout << (sum/terms) - (terms)/2 + i << " ";
}
}
cout << endl;
}
else
{
if (2*sum%terms != 0)
cout << "IMPOSSIBLE" << endl;
else
{
int d = (sum - terms)/(terms/2);
for (int i = 0; i < terms; i++) {
cout << 1-(d*(i - (terms/2))) << " ";
}
}
cout << endl;
}
}
}