题解 | 小欧的奇数

小欧的奇数

https://www.nowcoder.com/practice/aef41039765b433998812b9e9cfe02c2

#include <bits/stdc++.h>

using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0);
typedef long long LL;

//const int N=;

int main()
{
    IOS
    int n, x;
    int c0=0, c1=0;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>x;
        if(x&1) c1++;
        else c0++;
    }
    if(c1>=1){
        if(c1>=3 || c0>=2) cout<<"YES";
        else cout<<"NO";
    }
    else cout<<"NO";
    return 0;
}

奇数+奇数=偶数,偶数+偶数=偶数。首先三个数中必须存在奇数。其次必须有奇数个奇数。分类讨论即可

#牛客春招刷题训练营#

全部评论

相关推荐

04-30 15:51
已编辑
上海交通大学 机械工程师
点赞 评论 收藏
分享
已run的小章鱼很安静:跟他说毕业证学位证双证拿出来一个他单亲Null,拿两个他双亲是Null
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务