Codeforces Round #617 (Div. 3)A. Array with Odd Sum(水题)
You are given an array aa consisting of nn integers.
In one move, you can choose two indices 1≤i,j≤n1≤i,j≤n such that i≠ji≠j and set ai:=ajai:=aj . You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose ii and jj and replace aiai with ajaj ).
Your task is to say if it is possible to obtain an array with an odd (not divisible by 22 ) sum of elements.
You have to answer tt independent test cases.
The first line of the input contains one integer tt (1≤t≤20001≤t≤2000 ) — the number of test cases.
The next 2t2t lines describe test cases. The first line of the test case contains one integer nn (1≤n≤20001≤n≤2000 ) — the number of elements in aa . The second line of the test case contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤20001≤ai≤2000 ), where aiai is the ii -th element of aa .
It is guaranteed that the sum of nn over all test cases does not exceed 20002000 (∑n≤2000∑n≤2000 ).
For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
5
2
2 3
4
2 2 8 8
3
3 3 3
4
5 5 5 5
4
1 1 1 1
YES
NO
YES
NO
NO
读入时统计奇数和偶数的个数,奇数个数为0一定不行,只有偶数个奇数也一定不行,其他情况都可以。
#include <bits/stdc++.h>
using namespace std;
int t;
int main()
{
cin>>t;
while(t--)
{
int n;
cin>>n;
int i;
int ji=,ou=;
for(i=;i<=n;i++)
{
int temp;
scanf("%d",&temp);
if(temp%==)ou++;
else ji++;
}
if(ji==)
{
cout<<"NO"<<endl;
continue;
}
if(ou==&&ji%==)
{
cout<<"NO"<<endl;
continue;
}
cout<<"YES"<<endl;
}
return ;
}
Codeforces Round #617 (Div. 3)A. Array with Odd Sum(水题)的更多相关文章
- Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)
Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...
- Codeforces Round #373 (Div. 2) C. Efim and Strange Grade 水题
C. Efim and Strange Grade 题目连接: http://codeforces.com/contest/719/problem/C Description Efim just re ...
- Codeforces Round #185 (Div. 2) A. Whose sentence is it? 水题
A. Whose sentence is it? Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...
- Codeforces Round #373 (Div. 2) A. Vitya in the Countryside 水题
A. Vitya in the Countryside 题目连接: http://codeforces.com/contest/719/problem/A Description Every summ ...
- Codeforces Round #371 (Div. 2) A. Meeting of Old Friends 水题
A. Meeting of Old Friends 题目连接: http://codeforces.com/contest/714/problem/A Description Today an out ...
- Codeforces Round #355 (Div. 2) B. Vanya and Food Processor 水题
B. Vanya and Food Processor 题目连接: http://www.codeforces.com/contest/677/problem/B Description Vanya ...
- Codeforces Round #310 (Div. 2) B. Case of Fake Numbers 水题
B. Case of Fake Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...
- Codeforces Round #309 (Div. 2) B. Ohana Cleans Up 字符串水题
B. Ohana Cleans Up Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/554/pr ...
- Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks 字符串水题
A. Kyoya and Photobooks Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...
随机推荐
- 使用JDBC完成分类表CRUD的操作
工具类 通过之前的案例回顾,不难发现,有很多的代码操作是重复的,比如“获取链接”和“释放资源”等,将来在增删改查中经常遇到,开发中遇到这种情况,将采用工具类的方法进行抽取,从而达到代码的重复利用. 此 ...
- vim配置之——ctags与TagList的配置以及NERDTree && doxygentoolkit的安装
参考(2)vim插件:显示树形目录插件NERDTree安装 和 使用 本文档主要对Linux下vim的ctags,TagList,NerdTree与doxgentoolkit进行相关的配置. 以下部分 ...
- yum源文件
yum源文件 2017年11月22日 11:59:36 cakincqm 阅读数 1052更多 分类专栏: Linux 版权声明:本文为博主原创文章,遵循CC 4.0 by-sa版权协议,转载请附 ...
- redis 基础操作教程
1.linux 安装redis : Linux 下安装 下载地址:http://redis.io/download,下载最新稳定版本. 本教程使用的最新文档版本为 2.8.17,下载并安装: $ wg ...
- 分段函数&数学函数
本题要求计算下列分段函数f(x)的值(x为从键盘输入的一个任意实数): 输入格式: 直接输入一个实数x 输出格式: 在一行中按“f(x)=result”的格式输出,其中x与result都保留三位小数. ...
- 清华大学慕课 (mooc) 数据结构-邓俊辉-讲义-合并版
邓公的数据结构一直好评如潮,可惜我如今才开始学习它.QAQ 昨天,<数据结构 (2020 春)>的讲义已经推到清华大学云盘上了.苦于 10 拼页的打印版不易在 PC 上阅读(手机上更是如此 ...
- TensorFlow卷积神经网络实现手写数字识别以及可视化
边学习边笔记 https://www.cnblogs.com/felixwang2/p/9190602.html # https://www.cnblogs.com/felixwang2/p/9190 ...
- CSS选择器效率问题
今天学习了CSS各类选择器,对其效率问题有些疑问,故总结了一些学习笔记 有很多人都忘记了,或在简单的说没有意识到,CSS在我们手中,既能很高效,也可以变得很低能.这很容易被忘记,尤其是当你意识到你会的 ...
- HDFS的常用命令
一.常用命令 二.其他命令
- ASP.NET Core搭建多层网站架构【4-工作单元和仓储设计】
2020/01/28, ASP.NET Core 3.1, VS2019, Microsoft.EntityFrameworkCore.Relational 3.1.1 摘要:基于ASP.NET Co ...