【題解】Codeforces 1296A. Array with Odd Sum

【題目敘述】https://codeforces.com/contest/1296/problem/A

#include <iostream>
using namespace std;
 
int t, n, a, odd, even, total;
 
int main() {
    cin >> t;
    while (t--){
        cin >> n;
        odd = 0;
        even = 0;
        total = 0;
        for (int i = 0; i < n; i++){
            cin >> a;
            if (a % 2 == 0) even = 1;
            else odd = 1;
            total += a;
        }
        if ((odd == 0 || even == 0) && total % 2 == 0) cout << "NO\n";
        else cout << "YES\n";
    }
}
分享本文 Share with friends