<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      Codeforces Round #616 (Div. 2) A Even But Not Even 水題

      A. Even But Not Even

      time limit per test1 second
      memory limit per test256 megabytes

      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 → 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.

      Input

      The input consists of multiple test cases. The first line contains a single integer t (1≤t≤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≤n≤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.

      Output

      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.

      Example

      input
      4
      4
      1227
      1
      0
      6
      177013
      24
      222373204424185217171912
      output
      1227
      -1
      17703
      2237344218521717191

      Note

      In the first test case of the example, 1227 is already an ebne number (as 1+2+2+7=12, 12 is divisible by 2, while in the same time, 1227 is not divisible by 2) so we don't need to delete any digits. Answers such as 127 and 17 will also be accepted.

      In the second test case of the example, it is clearly impossible to create an ebne number from the given number.

      In the third test case of the example, there are many ebne numbers we can obtain by deleting, for example, 1 digit such as 17703, 77013 or 17013. Answers such as 1701 or 770 will not be accepted as they are not ebne numbers. Answer 013 will not be accepted as it contains leading zeroes.

      Explanation:

      1+7+7+0+3=18. As 18 is divisible by 2 while 17703 is not divisible by 2, we can see that 17703 is an ebne number. Same with 77013 and 17013;
      1+7+0+1=9. Because 9 is not divisible by 2, 1701 is not an ebne number;
      7+7+0=14. This time, 14 is divisible by 2 but 770 is also divisible by 2, therefore, 770 is not an ebne number.
      In the last test case of the example, one of many other possible answers is given. Another possible answer is: 222373204424185217171912 → 22237320442418521717191 (delete the last digit).

      題意

      給你長(zhǎng)度為n的字符串s,讓你從字符串中刪除一些數(shù)字,然后使得這個(gè)字符串組成的數(shù)字是一個(gè)合法的,所有數(shù)字和加起來(lái)是偶數(shù),但這個(gè)數(shù)字是奇數(shù)的一個(gè)字符串。

      題解

      視頻題解:https://www.bilibili.com/video/av86529667/

      數(shù)字和為偶數(shù)的奇數(shù),我們倒著找第一個(gè)奇數(shù),以奇數(shù)結(jié)尾的數(shù)一定是奇數(shù)。

      數(shù)字和為偶數(shù),就是里面有偶數(shù)個(gè)奇數(shù),這個(gè)我們判斷一下里面有幾個(gè),如果是奇數(shù),我們就減去最后一個(gè)。特殊情況是只有1個(gè)奇數(shù)的時(shí)候。

      代碼

      #include<bits/stdc++.h>
      using namespace std;
       
      void solve(){
          int n;
          string s;
          cin>>n>>s;
          int len = -1;
          for(int i=s.size()-1;i>=0;i--){
              if((s[i]-'0')%2==1){
                  len=i;
                  break;
              }
          }
          if(len==-1){
              cout<<"-1"<<endl;
              return;
          }
          int num = 0;
          for(int i=0;i<=len;i++){
              if((s[i]-'0')%2==1){
                  num++;
              }
          }
          if(num%2==0){
              for(int i=0;i<=len;i++){
                  cout<<s[i];
              }
              cout<<endl;
              return;
          }else{
              if(num==1){
                  cout<<"-1"<<endl;
                  return;
              }
              int flag = -1;
              for(int i=len-1;i>=0;i--){
                  if((s[i]-'0')%2==1){
                      flag=i;
                      break;
                  }
              }
              for(int i=0;i<=len;i++){
                  if(i==flag)continue;
                  cout<<s[i];
              }
              cout<<endl;
          }
      }
      int main(){
          int t;
          cin>>t;
          while(t--){
              solve();
          }
      }
      
      posted @ 2020-02-03 19:08  qscqesze  閱讀(537)  評(píng)論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 免费看成人欧美片爱潮app| 2021国产精品视频网站| japanese边做边乳喷| 精品少妇人妻av无码专区| 国产一区二区黄色激情片| 麻豆a级片| 极品无码国模国产在线观看| 国产仑乱无码内谢| 九色综合狠狠综合久久| 伊人久久大香线蕉综合网站| 日韩中文字幕国产精品| 欧日韩无套内射变态| 国产激情一区二区三区不卡| 国产老妇伦国产熟女老妇高清| 少妇特殊按摩高潮惨叫无码| 视频一区二区三区刚刚碰 | 国内精品无码一区二区三区| 欧美激情肉欲高潮视频| 亚欧洲乱码视频在线专区| 久久这里有精品国产电影网| 无码高潮爽到爆的喷水视频app| 无码少妇一区二区| AV区无码字幕中文色| 久久午夜无码免费| 中文字幕日韩国产精品| 一区二区三区四区精品视频| 无码国产偷倩在线播放老年人 | 内射老妇bbwx0c0ck| 国产精品综合色区在线观| 巨爆乳中文字幕爆乳区| 亚洲人成色77777| 亚洲av专区一区| 亚洲另类无码一区二区三区| 国产最大成人亚洲精品| 久久香蕉国产线看观看怡红院妓院| 国产亚洲精品久久777777| 久久精品夜色国产亚洲av| 久久天天躁夜夜躁狠狠| 国产睡熟迷奷系列网站| 亚洲精品一区二区三区蜜| 久久波多野结衣av|