-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA.cpp
51 lines (43 loc) · 979 Bytes
/
A.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
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll t;
cin>>t;
while(t--){
ll n,k;
cin>>n>>k;
ll ans=0;
ll a[n], j=0;
for(int i=n; i>=1; i--){
if(i==k) continue;
if(i>k){
ans++;
a[j]=i;
j++;
}
else{
int flag=0;
for(int z=0; z<ans; z++){
if(a[z]+i == k){
flag=1;
break;
}
}
if(flag==0){
ans++;
a[j]=i;
j++;
}
}
}
cout<<ans<<"\n";
for(int l=0; l<ans; l++) cout<<a[l]<<" ";
cout<<"\n";
}
return 0;
}