题解 | #小欧的奇数#

小欧的奇数

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

判断奇数和偶数的个数是否合法。

#include<bits/stdc++.h>
#define int long long
#define double long double
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef pair<int, int> PII;
const int N = 3e5 + 10;
const int M = 1e3 + 10;
int mod = 1e9 + 7;
int a[N];

void solve() {
    int c1 = 0, c2 = 0;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (x % 2) c1++;
        else c2++;
    }
    if (c1 >= 3 || (c1 >= 1 && c2 >= 2)) cout << "YES\n";
    else cout << "NO\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int _;
    _ = 1;
    //cin>>_;
    while (_--) {
        solve();
    }
}

全部评论

相关推荐

今天 17:11
已编辑
微软_sde(实习员工)
美团已拒/京东已拒/快手已拒/虾皮已拒/百度已拒/字节已拒
牛牛爱吃草草:日本可以理解
投递美团等公司10个岗位
点赞 评论 收藏
分享
09-26 19:45
门头沟学院 Java
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务