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 ...
随机推荐
- 连接查询:inner join,left join,right join
感谢原创:https://blog.csdn.net/plg17/article/details/78758593 准备工作: 1)新建两张表a_table和b_table: create table ...
- html - html5 audio 音乐自动播放,循环播放等
转自:http://blog.csdn.net/u012246458/article/details/50618759 audio播放音乐 <audio id="audio" ...
- Linux下tail命令的使用方法
Linux下tail命令的使用方法: linux tail命令用途是依照要求将指定的文件的最后部分输出到标准设备,通常是终端,通俗讲来,就是把某个档案文件的最后几行显示到终端上,假设该档案有更新,ta ...
- 七、linux基础-jdk1.8和weblogic12.2.1.3.0安装
1.环境探查与准备 安装jdk和weblogic前需要对进行安装的linux系统硬件和软件环境进行探查确认,以确保支持对jdk1.8.0_144_1和weblogic12.2.1.3和的安装.webl ...
- HttpClient与TestNG结合
1.HTTPclient插件的安装 在maven项目的pom.xml中引用HTTPclient包,如下 <dependencies> <dependency> <grou ...
- jmeter实现对Oracle数据库的操作
实现目的 有时候,根据业务需要,可能需要直接对数据库进行性能测试,此时可利用jmeter对Oracle.MySQL等数据库进行相关测试. 脚本实现 添加JDBC Connection Configur ...
- 攻防世界 你知道什么是cookie吗?
打开题目链接,提示我们查看cookie,cookie是HTTP协议中的一个重要参数,(对HTTP协议不是很熟悉的friends可以看看这个“HTTP协议其实就是这么简单”) 查看cookie的方法有很 ...
- 1011 World Cup Betting
Title:1011 World Cup Betting 1. 注意点 比较简单,没有注意点 2. python3代码 def func(output): max = 0 index = -1 lin ...
- c语言实现面向对象编程
1.通用校验器接口(validator.h) #ifndef VALIDATOR_H_INCLUDED #define VALIDATOR_H_INCLUDED #include<stdbool ...
- LCT 维护边双 / 点双的模板
用 \(\text{LCT}\) 维护边双的做法是:加入一条非树边时,将这段树上路径合并为一个点代表这个边双,具体实现用并查集合并点,在 \(\text{Splay}\) 与 \(\text{Acce ...