题意:给你一个数组,你每次可以是其中一个数减一,数组其他元素加一,问是否能够相等,这个数组的所有元素。

解题思路:将数组从小到大排序,只要后一项减去当前项的值是奇数就行了。

代码:

#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的更多相关文章

  1. 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 ...

  2. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

  3. ACM: Gym 101047E Escape from Ayutthaya - BFS

    Gym 101047E Escape from Ayutthaya Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I6 ...

  4. ACM: Gym 101047B Renzo and the palindromic decoration - 手速题

     Gym 101047B  Renzo and the palindromic decoration Time Limit:2000MS     Memory Limit:65536KB     64 ...

  5. Gym 101102J---Divisible Numbers(反推技巧题)

    题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...

  6. Gym 100917J---Judgement(01背包+bitset)

    题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...

  7. Gym 100917J---dir -C(RMQ--ST)

    题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...

  8. Gym 101102D---Rectangles(单调栈)

    题目链接 http://codeforces.com/gym/101102/problem/D problem  description Given an R×C grid with each cel ...

  9. Gym 101102C---Bored Judge(区间最大值)

    题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...

  10. 2016"百度之星" - 初赛(Astar Round2A)Gym Class(拓扑排序)

    Gym Class  Accepts: 849  Submissions: 4247  Time Limit: 6000/1000 MS (Java/Others)  Memory Limit: 65 ...

随机推荐

  1. BZOJ3601 一个人的数论 莫比乌斯反演、高斯消元/拉格朗日插值

    传送门 题面图片真是大到离谱-- 题目要求的是 \(\begin{align*}\sum\limits_{i=1}^N i^d[gcd(i,n) == 1] &= \sum\limits_{i ...

  2. C# WPF仿360安全卫士11

    首先上效果图: 这是我的第一篇随笔,最近因为写一个播放器,开始学习WPF相关技术,随着不断入坑,播放器倒是做出来了,掉坑里了... 本着闲着也是闲着的精神,拿360开刀了: 主界面主要使用DMSkin ...

  3. 2018 Multi-University Training Contest 1

    比赛链接:2018 Multi-University Training Contest 1 6301 Distinct Values 题意:输出一个长度为n的序列,要求满足m个区间的数都不相同,并且字 ...

  4. [2019BUAA软工助教]Alpha阶段无人转出申请审核结果

    [2019BUAA软工助教]Alpha阶段无人转出申请审核结果 一.队伍信息 队伍名 项目 人数 红太阳 社团 8(6+2) pureman 博客园 6 水哥牛逼 招募 6 葫芦娃 拖拽Pytorch ...

  5. static特别用法【静态导包】——Java包的静态导入

    面试我问你static关键字有哪些作用,如果你答出static修饰变量.修饰方法我会认为你合格,答出静态块,我会认为你不错,答出静态内部类我会认为你很好,答出静态导包我会对你很满意,因为能看出你非常热 ...

  6. js-XMLHttpRequest 2级

    ###1. XMLHttpRquest 2级 1)   FormData 现代web应用中频繁使用的一项功能就死表单数据的序列化, XMLHttpRquest 2级为此定义了FormData类型 Fo ...

  7. ES7的新特性

    ES7的新特性 ES7 特性: 1.Array.prototype.includes2.Exponentiation Operator(求幂运算) 一,Array.prototype.includes ...

  8. Js中instanceof 的用法

    在 JavaScript 中,判断一个变量的类型尝尝会用 typeof 运算符,在使用 typeof 运算符时采用引用类型存储值会出现一个问题,无论引用的是什么类型的对象,它都返回 “object”. ...

  9. 牛客练习赛13D 幸运数字4

    题目链接:https://ac.nowcoder.com/acm/contest/70/D 题目大意: 略 分析: 注意到12! < 10^9 < 13!,于是当n > 13时,第k ...

  10. Spark 数据倾斜

    Spark 数据倾斜解决方案 2017年03月29日 17:09:58 阅读数:382 现象       当你的应用程序发生以下情况时你该考虑下数据倾斜的问题了: 绝大多数task都可以愉快的执行,总 ...