-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathebne.cpp
More file actions
executable file
·64 lines (63 loc) · 721 Bytes
/
ebne.cpp
File metadata and controls
executable file
·64 lines (63 loc) · 721 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
60
61
62
63
64
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
// your code goes hee
ll t;
cin>>t;
while(t--)
{
ll n;
cin>>n;
string s;
cin>>s;
for(ll i=n-1;i>-1;i--)
{
if((s[i]-'0')%2==0)
{
s.erase(s.begin()+i);
}
}
n=s.size();
if(n==0)
{
cout<<"-1\n";
continue;
}
ll sum=0;
n=s.size();
ll od=0;
for(ll i=0;i<n;i++)
{
sum+=s[i]-'0';
if((s[i]-'0')%2)
{
od++;
}
}
if(sum%2==0)
{
cout<<s<<"\n";
continue;
}
if(od==1)
{
cout<<"-1\n";
continue;
}
ll tr=1;
for(ll i=0;i<n;i++)
{
if((s[i]-'0')%2==0 || tr==0)
{
cout<<s[i];
}
else
{
tr=0;
}
}
cout<<"\n";
}
return 0;
}