-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1715B.cpp
More file actions
36 lines (30 loc) · 827 Bytes
/
1715B.cpp
File metadata and controls
36 lines (30 loc) · 827 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int main() {
int t; cin >> t;
while (t--) {
long long n, k, b, s;
cin >> n >> k >> b >> s;
long long min_required = k * b;
long long max_possible = k * b + (n - 1) * (k - 1);
if (s < min_required || s > max_possible + (k - 1)) {
cout << -1 << endl;
continue;
}
vector<long long> ans(n, 0);
ans[0] = min(s, k * b + k - 1);
s -= ans[0];
for (int i = 1; i < n; ++i) {
long long take = min(s, k - 1);
ans[i] = take;
s -= take;
}
if (s > 0) {
cout << -1 << endl;
} else {
for (auto x : ans) cout << x << " ";
cout << endl;
}
}
return 0;
}