Skip to content

Commit af25b7f

Browse files
authored
Create 1772C. Different Differences.cpp
1 parent 58ff2fa commit af25b7f

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
int main() {
6+
int t;
7+
cin >> t;
8+
9+
while(t-- != 0) {
10+
int n, k;
11+
cin >> k >> n;
12+
13+
int elements = 0, last = 0;
14+
for(int i = 1, j = 1;; i += j, ++j) {
15+
if(elements == k || k - (elements + 1) > n - i) {
16+
break;
17+
}
18+
19+
cout << i << ' ';
20+
last = i;
21+
++elements;
22+
}
23+
24+
while(elements < k) {
25+
cout << ++last << ' ';
26+
++elements;
27+
}
28+
29+
puts("");
30+
31+
}
32+
33+
return 0;
34+
}

0 commit comments

Comments
 (0)