Gym
来源:互联网 发布:闪电战2mac版无限子弹 编辑:程序博客网 时间:2024/04/28 23:20
In a magical forest, there exists N bamboos that don't quite get cut down the way you would expect.
Originally, the height of the ith bamboo is equal tohi. In one move, you can push down a bamboo and decrease its height by one, but this move magically causes all the other bamboos to increase in height by one.
If you can do as many moves as you like, is it possible to make all the bamboos have the same height?
The first line of input is T – the number of test cases.
The first line of each test case contains an integer N(1 ≤ N ≤ 105) - the number of bamboos.
The second line contains N space-separated integershi(1 ≤ hi ≤ 105) - the original heights of the bamboos.
For each test case, output on a single line "yes” (without quotes), if you can make all the bamboos have the same height, and "no" otherwise.
232 4 221 2
yesno
思路:只要相邻数的差为偶数即可
ac代码:
#include <iostream>#include <algorithm>#include <math.h>#include <stdio.h>#include <stdlib.h>using namespace std;int main(){ int n,x,y; cin>>n; while(n--) { scanf("%d",&x); scanf("%d",&y); int k=y; int flag=0; for(int i=1;i<x;i++) { scanf("%d",&y); if((y-k)%2!=0) flag=1; } if(flag==0) printf("yes\n"); else printf("no\n"); } return 0;}
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- HTML中的<select>标签如何设置默认选中的选项
- Linux基础学习之bash shell内置命令----type
- 大整数的4则运算
- POJ
- BroadcastReceiver使用详解
- Gym
- python学习笔记(九)函数式进阶:使用map、reduce、filter、sorted
- 正则表达式特殊字符
- lec2 PC Programming & Booting 学习笔记
- UVA
- numpy学习笔记-用于布尔型数组的方法
- 获取时间
- 动态顺序表的实现(c语言版本)
- Spring MVC源码分析