gym-101350D
题意:给你一个数组,你每次可以是其中一个数减一,数组其他元素加一,问是否能够相等,这个数组的所有元素。
解题思路:将数组从小到大排序,只要后一项减去当前项的值是奇数就行了。
代码:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
int t,n;
int a[100005];
int flag;
cin>>t;
while(t--)
{
flag=0;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
sort(a+1,a+1+n);
for(int i=1;i<n;i++)
{
if(abs(a[i+1]-a[i])%2==1)
flag=1;
}
if(flag==1)
printf("no\n");
else
printf("yes\n");
}
return 0;
}
gym-101350D的更多相关文章
- ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力
Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS Memory Limit:65536KB 64bit IO Fo ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- Gym 101102J---Divisible Numbers(反推技巧题)
题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...
- Gym 100917J---Judgement(01背包+bitset)
题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...
- Gym 100917J---dir -C(RMQ--ST)
题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...
- Gym 101102D---Rectangles(单调栈)
题目链接 http://codeforces.com/gym/101102/problem/D problem description Given an R×C grid with each cel ...
- Gym 101102C---Bored Judge(区间最大值)
题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...
- 2016"百度之星" - 初赛(Astar Round2A)Gym Class(拓扑排序)
Gym Class Accepts: 849 Submissions: 4247 Time Limit: 6000/1000 MS (Java/Others) Memory Limit: 65 ...
随机推荐
- Mac环境 安装brew
一.brew官网主页上的方法: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/insta ...
- Linux每天一个命令:grep
grep (缩写来自Globally search a Regular Expression and Print) 是一种强大的文本搜索工具,它能使用特定模式匹配(包括正则表达式)搜索文本,并默认输出 ...
- Maven 多模块引用版本的问题 java.lang.NoSuchMethodError
环境:Junit测试用例 java.lang.NoSuchMethodError 很明显的错误,肯定是jar版本的问题 前提 Maven 打包并没有这个的问题,估计是做了优化处理 原测试代码 @Run ...
- Leetcode 153. Find Minimum in Rotated Sorted Array -- 二分查找的变种
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e. ...
- Ordering Tasks
链接 [https://vjudge.net/contest/281085#problem/D] 题意 有n个任务,有M个对先后顺序 然你输出最后的完成任务的顺序,有多种可能输出一种即可 分析 裸的拓 ...
- Iar8.1安装包破解
Iar8.1安装包链接链接:https://pan.baidu.com/s/1F6sxEcatk3_YPq47lvc8Mw 密码:mnlz 破解链接 https://www.cnblogs.com/ ...
- openstack-虚拟化模型
一. 虚拟化模型 1.虚拟化模型 图1 虚拟化模型 图2 KVM架构 2.KVM模块 处理器虚化 内存虚化 3.QEMU设备模型 其它虚化(网卡.声卡.显卡等)
- 使用PHPExcel导出数据库表结构及内容
导出表结构: mysql> desc user ; +----------+--------------+------+-----+---------------------+--------- ...
- tomcat redis 集群 session共享
jcoleman/tomcat-redis-session-manager: Redis-backed non-sticky session store for Apache Tomcathttps: ...
- Spring、MyBatis、Shiro、Quartz、Activiti框架
https://www.renren.io/ 人人开源:基于Spring.MyBatis.Shiro框架,开发的一套后台脚手架框架(权限系统),极低门槛,拿来即用.支持分布式部署.Quartz分布式集 ...