-
Notifications
You must be signed in to change notification settings - Fork 0
/
C.cpp
43 lines (41 loc) · 993 Bytes
/
C.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
// time-limit: 1000
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, x, y, p, numInRange;
cin >> n >> x >> y;
int dif = y - x;
vector<int> div;
for (p = 1; p <= dif; ++p)
if (dif % p == 0)
div.emplace_back(p);
for (auto& i : div) {
numInRange = dif / i + 1;
if (numInRange <= n) {
p = i;
break;
}
}
//cout << p << " " << numInRange << "\n";
//return;
n -= numInRange;
for (int i = x - p; i > 0 && n > 0; i -= p, --n) {
cout << i << " ";
}
for (int i = x; i <= y; i += p)
cout << i << " ";
while (n--)
cout << (y += p) << " ";
cout << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}