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 ...
随机推荐
- Day0 认识Java与变量类型
字节码与虚拟机 Java介于编译型语言和解释型语言之间.编译型语言如C.C++,代码是直接编译成机器码执行,但是不同的平台(x86.ARM等)CPU的指令集不同,因此,需要编译出每一种平台的对应机器码 ...
- Go并发介绍
1. 进程.线程.协程 进程(Process),线程(Thread),协程(Coroutine,也叫轻量级线程) 进程 进程是一个程序在一个数据集中的一次动态执行过程,可以简单理解为“正在执行的程序” ...
- ALSA lib基本概念
1.channel 通道,即我们熟知的声道数.左/右声道,5.1channel等等 2.sample A sample is a single value that describes the amp ...
- 京东秒杀抢购的小脚本和chorme的一个开发者插件
chorme开发者插件 下载源码包:https://github.com/gongjunhao/seckill/archive/master.zip 解压:seckill-master.zip 打开c ...
- animation模块的使用
1.动画的实现-初探 import numpy as np import matplotlib.pyplot as plt from matplotlib.animation import FuncA ...
- python-用正则表达式筛选文本信息
[摘要] 本文主要介绍如何对多个文本进行读取,并采用正则表达式对其中的信息进行筛选,将筛选出来的信息存写到一个新文本. 打开文件:open(‘文件名’,‘打开方式’)>>>file ...
- MongoDB - 用户名密码认证
参考 offical doc medium Mongo roles说明 https://docs.mongodb.com/manual/reference/built-in-roles/#userAd ...
- 企业级Docker镜像仓库Harbor部署与使用
yum install docker 官网地址:https://docs.docker.com/compose/install/ 运行此命令以下载Docker Compose的当前稳定版本 1 sud ...
- Jenkins+Maven+Github+Springboot实现可持续自动部署(非常详细)
目前公司开发的项目已经部署到服务器上,部署项目的测试环境和生产环境,加上每个项目n个服务,于是我就 , 骚就是骚,但是就是太累了,于是花点时间研究了一下Jenkins. Jenkins的作用和它的lo ...
- PLSQL用户登录时报错: no listener
报错原因是因为服务没有开启,找到oracle的相应服务开启即可.