307034: CF1291A. Even But Not Even
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Even But Not Even
题意翻译
有 $T$ 组数据. 给你一个长为 $N$ 的非负数字串. 现在你需要从这个串里删掉 $0\leq k \leq N-1$ 个数码 ( 这些数码可以不连续 ) , 使这个数字串形成的数不能被 $2$ 整除, 但是这些数码的和可以被 $2$ 整除. 输出处理后的数字串. 如果给定的数字串无法通过删掉一些数码来满足要求,输出 $−1$. 数据范围: $1 \leq T \leq 1000, 1\leq N \leq 3000$.题目描述
Let's define a number ebne (even but not even) if and only if its sum of digits is divisible by $ 2 $ but the number itself is not divisible by $ 2 $ . For example, $ 13 $ , $ 1227 $ , $ 185217 $ are ebne numbers, while $ 12 $ , $ 2 $ , $ 177013 $ , $ 265918 $ are not. If you're still unsure what ebne numbers are, you can look at the sample notes for more clarification. You are given a non-negative integer $ s $ , consisting of $ n $ digits. You can delete some digits (they are not necessary consecutive/successive) to make the given number ebne. You cannot change the order of the digits, that is, after deleting the digits the remaining digits collapse. The resulting number shouldn't contain leading zeros. You can delete any number of digits between $ 0 $ (do not delete any digits at all) and $ n-1 $ . For example, if you are given $ s= $ 222373204424185217171912 then one of possible ways to make it ebne is: 222373204424185217171912 $ \rightarrow $ 2237344218521717191. The sum of digits of 2237344218521717191 is equal to $ 70 $ and is divisible by $ 2 $ , but number itself is not divisible by $ 2 $ : it means that the resulting number is ebne. Find any resulting number that is ebne. If it's impossible to create an ebne number from the given number report about it.输入输出格式
输入格式
The input consists of multiple test cases. The first line contains a single integer $ t $ ( $ 1 \le t \le 1000 $ ) — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $ n $ ( $ 1 \le n \le 3000 $ ) — the number of digits in the original number. The second line of each test case contains a non-negative integer number $ s $ , consisting of $ n $ digits. It is guaranteed that $ s $ does not contain leading zeros and the sum of $ n $ over all test cases does not exceed $ 3000 $ .
输出格式
For each test case given in the input print the answer in the following format: - If it is impossible to create an ebne number, print "-1" (without quotes); - Otherwise, print the resulting number after deleting some, possibly zero, but not all digits. This number should be ebne. If there are multiple answers, you can print any of them. Note that answers with leading zeros or empty strings are not accepted. It's not necessary to minimize or maximize the number of deleted digits.
输入输出样例
输入样例 #1
4
4
1227
1
0
6
177013
24
222373204424185217171912
输出样例 #1
1227
-1
17703
2237344218521717191