题意:像13,1227这样的数是ebne,12,2,177013这样的数不是,ebne是一个数位和是偶数的奇数。题目给出一个数求这个数能否通过删除任意位数(不能出现前导零)成为一个ebne,如果可以,输出任意一个经过删除后形成的ebne,如果不可以,输出-1。
题解:如果这样一个数里有不少于2个奇数,那么可以,输出这两个奇数,如果不可以,输出-1。
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t; cin >> t;
while (t--) {
int n; cin >> n;
string s; cin >> s;
int odd = 0;
for (char c : s) if ((c - '0') & 1) odd++;
if (odd <= 1) { cout << "-1\n"; continue; }
int cnt = 0;
for (char c : s) {
if ((c - '0') & 1) { cout << c; cnt++; }
if (cnt == 2) break;
}
cout << '\n';
}
return 0;
}