Magical Bamboos Gym
来源:互联网 发布:猪年春晚不提猪 知乎 编辑:程序博客网 时间:2024/06/06 01:32
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 to hi. 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 integers hi (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
就是找规律呗,自己写几组数就找到规律了
排序后不能有两个相邻的差为1或者差对二取余不为零
#include <iostream>#include <algorithm>#include <cstdio>#include <cmath>#include <cstring>#include <string>#include <string.h>#include <map>#include <set>#include <queue>#include <deque>#include <list>#include <bitset>#include <stack>#include <stdlib.h>#define lowbit(x) (x&-x)using namespace std;int a[100005];int main(){ int t; cin>>t; while(t--) { memset(a,0,sizeof(a)); int n; cin>>n; for(int i=0;i<n;i++) scanf("%d",&a[i]); sort(a,a+n); int flag = 1; for(int i=1;i<n;i++) { //cout<<a[i]<<endl; if((a[i]-a[i-1]==1)||(a[i]-a[i-1])%2!=0) { flag = 0; cout<<"no"<<endl; break; } } if(flag) cout<<"yes"<<endl; } return 0;}
- Magical Bamboos Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- android条形图绘制以及加入动画,并且支持水平滑动
- uboot内核传参—cmdline常用参数
- 在线购物平台领域类图
- 多项式求和
- CCF NOI1024 因子个数
- Magical Bamboos Gym
- ACM中无穷大,无穷小的设定
- MySQL中secure-file-priv 配置项对数据导入导出的影响
- rhel小测试
- 我的Linux学习二(CentOS 7的网络配置)
- 5-5 回文判断 (20分)
- poj 3254 Corn Fields 状压dp
- F. Palindrome
- Java 抽象类