-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4.cpp
54 lines (36 loc) · 858 Bytes
/
4.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
#include <bits/stdc++.h>
using namespace std;
#define ll long long
signed main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int tc = 0, tt = 1;
cin >> tt;
while (tc++ < tt)
{
ll n, k;
cin >> n >> k;
vector<ll> arr(1, 1);
k -= n;
ll curr = 2;
for (int i = 2; i <= n; i++) {
if (k < arr.size()) {
int val = arr[arr.size()- k- 1];
arr.push_back(val);
break;
}
k -= arr.size();
arr.push_back(curr);
curr++;
}
while (arr.size() < n) {
arr.push_back(arr.back());
}
for(auto x: arr){
cout << x << " ";
}cout << endl;
}
return 0;
}