-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday_con_co_tong_le.cpp
More file actions
59 lines (59 loc) · 978 Bytes
/
day_con_co_tong_le.cpp
File metadata and controls
59 lines (59 loc) · 978 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int b[10000];
void snt(int m){
for(int i=0;i<m;i++) b[i]=1;
b[0]=0;b[1]=0;
for(int i=2;i<m;i++){
if(b[i]){
for(int j=i*i;j<m;j+=i) b[j]=0;
}
}
}
int n;
vector<int> a;
int check(string s){
int sum=0;
for(int i=0;i<s.size();i++){
if(s[i]=='1') sum+=a[i];
}
return (sum%2);
}
void init(){
cin >> n;
a.clear();
a.resize(n);
for(int i=0;i<n;i++) cin >> a[i];
sort(a.begin(),a.end(),greater<int>());
}
void Try(string s){
if(s.size()==n){
if(check(s)==1){
for(int i=0;i<s.size();i++){
if(s[i]=='1') cout << a[i] <<" ";
}
cout << "\n";
}
}
else {
Try(s+"0");
Try(s+"1");
}
}
void slove(){
init();
Try("");
}
int main(){
fast;
int t=1;
cin >> t;
snt(9999);
while(t--){
slove();
}
return 0;
}