codeforces round #616 div2 A (Even but not even)水题

水题:

链接:https://codeforces.com/contest/1291/problem/A

题意:给一个字符数组,删去数组中的一些数,使得剩下的数字的和为偶数,其中的数字有偶数多个奇数且首尾数字为奇数

找两个奇数就满足题意了:

代码:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define maxx 1010
const int maxn=3e5+10;
int n;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
    scanf("%d",&n);
    char s[maxn];
    scanf("%s",s);
    string ch="";
    int flag=0;
    for(int i=0; i<n; i++)
    {
        if((s[i]-‘0‘)&1)
            ch+=s[i];
        if(ch.size()>=2)
        {
            flag=1;
            break;
        }
    }
    if(flag)
        cout<<ch<<endl;
    else printf("-1\n");
    }
    return 0;}

原文地址:https://www.cnblogs.com/sweetlittlebaby/p/12661437.html

时间: 2024-11-09 00:08:30

codeforces round #616 div2 A (Even but not even)水题的相关文章

Codeforces Round #337 (Div. 2) B. Vika and Squares 水题

B. Vika and Squares Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i. Vika also has an infinitely long rectangular piece of paper of width 1, consisting of s

Codeforces Round #281 (Div. 2) B. Vasya and Wrestling 水题

B. Vasya and Wrestling Vasya has become interested in wrestling. In wrestling wrestlers use techniques for which they are awarded points by judges. The wrestler who gets the most points wins. When the numbers of points of both wrestlers are equal, th

Codeforces Round #632 (Div. 2) A. Little Artem(水题)

Young boy Artem tries to paint a picture, and he asks his mother Medina to help him. Medina is very busy, that's why she asked for your help. Artem wants to paint an n×mn×m board. Each cell of the board should be colored in white or black. Lets BB be

Educational Codeforces Round 85 B. Middle Class(排序/贪心/水题)

Many years ago Berland was a small country where only nn people lived. Each person had some savings: the ii -th one had aiai burles. The government considered a person as wealthy if he had at least xx burles. To increase the number of wealthy people

codeforces round #257 div2 C、D

本来应该认真做这场的,思路都是正确的. C题,是先该横切完或竖切完,无法满足刀数要求,再考虑横切+竖切(竖切+横切), 因为横切+竖切(或竖切+横切)会对切割的东西产生交叉份数,从而最小的部分不会尽可能的大. 代码如下,虽然比较长.比较乱,但完全可以压缩到几行,因为几乎是4小块重复的代码,自己也懒得压缩 注意一点,比如要判断最小块的时候,比如9行要分成2份,最小的剩下那份不是9取模2,而应该是4 m/(k+1)<=m-m/(k+1)*k          #include<bits/stdc+

codeforces Round #250 (div2)

a题,就不说了吧 b题,直接从大到小排序1-limit的所有数的lowbit,再从大到小贪心组成sum就行了 1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<cstring> 5 #define N 200000 6 using namespace std; 7 int pos[N],a[N],s[N],f[N],la[N],b[N],i,j,k,ans,n,p

Codeforces Round#320 Div2 解题报告

Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Finding Team Member codeforces 579C A Problem about Polyline codeforces 579D "Or" Game codeforces 579E Weakness and Poorness codeforces 579F LCS Aga

Codeforces Round #254(div2)A

很有趣的题.想到了就非常简单,想不到就麻烦了. 其实就是一种逆向思维:最后结果肯定是这样子: WBWBWBWB... BWBWBWBW... WBWBWBWB... ... 里面有“-”的地方改成“-”就行了. 但是我开始是正着想的,想每个点怎么处理,这还要看它周围点的状态,越想越麻烦... 这题中体现的正难则反的逆向思维很值得学习. #include<iostream> #include<cstdio> #include<cstdlib> #include<cs

Codeforces Round #254(div2)B

就是看无向图有几个连通块,答案就是2n-num. 范围很小,就用矩阵来存图减少代码量. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<map> #include<set> #include<vector> #include<algorithm> #inc