hdu 5146(水题)
Sequence
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 924 Accepted Submission(s): 499
Nero
thinks a number sequence A is good only if the sum of its elements with
odd index equals to the sum of its elements with even index and this
sequence is not a palindrome.
Palindrome means no matter we read the sequence from head to tail or from tail to head,we get the same sequence.
Two
sequence A and B are consider different if the length of A is different
from the length of B or there exists an index i that Ai≠Bi.
Now,give you the sequence A,check out it’s good or not.
Each test case begins with a line contains an integer n,the length of sequence A.
The next line follows n integers A1,A2,…,An.
[Technical Specification]
1 <= T <= 100
1 <= n <= 1000
0 <= Ai <= 1000000
7
1 2 3 4 5 6 7
7
1 2 3 5 4 7 6
6
1 2 3 3 2 1
Yes
No
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <stdlib.h>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = ;
int n,a[N];
bool test1(){
LL sum1 = ,sum2 = ;
for(int i=;i<=n;i+=){
sum1+=a[i];
}
for(int i=;i<=n;i+=){
sum2+=a[i];
}
if(sum1==sum2) return true;
return false;
}
bool test2(){
for(int i=,j=n;i<j;i++,j--){
if(a[i]!=a[j]) return true;
}
return false;
}
int main()
{
int tcase;
scanf("%d",&tcase);
while(tcase--)
{
scanf("%d",&n);
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
}
if(test1()&&test2()) printf("Yes\n");
else printf("No\n");
}
return ;
}
hdu 5146(水题)的更多相关文章
- HDU-1042-N!(Java大法好 && HDU大数水题)
N! Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Subm ...
- HDU 5391 水题。
E - 5 Time Limit:1500MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- hdu 1544 水题
水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...
- HDU排序水题
1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...
- hdu 2710 水题
题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...
- Dijkstra算法---HDU 2544 水题(模板)
/* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...
- hdu 5162(水题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...
- hdu 3357 水题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...
- hdu 5038 水题 可是题意坑
http://acm.hdu.edu.cn/showproblem.php?pid=5038 就是求个众数 这个范围小 所以一个数组存是否存在的状态即可了 可是这句话真恶心 If not all ...
随机推荐
- laravel5.5用户认证
目录 1. 命令 2. 快速认证 2.1 自定义路径 2.2 自定义用户名 2.3 自定义看守器 2.4 自定义验证/存储 2.5 Auth::xx() 2.6 保护路由 2.7 指定看守器 3 手动 ...
- 剑指Offer - 九度1352 - 和为S的两个数字
剑指Offer - 九度1352 - 和为S的两个数字2014-02-05 18:15 题目描述: 输入一个递增排序的数组和一个数字S,在数组中查找两个数,是的他们的和正好是S,如果有多对数字的和等于 ...
- 《Cracking the Coding Interview》——第7章:数学和概率论——题目1
2014-03-20 01:57 题目:玩篮球投篮,有两种玩法:要么1投1中,要么3投两中.你单次投篮中的概率是p,那么对于不同的p,哪种玩法胜率更高? 解法:第一种总是胜率更高,可以列不等式算算,结 ...
- Pascal小游戏 打飞机
一个经典的打飞机游戏(1)Pascal代码 十分经典,有一种街机的感觉 奇葩青年的又一控制台神作. uses crt; type list=record ty,ax:integer; ...
- leetcode 【Rotate List 】python 实现
题目: Given a list, rotate the list to the right by k places, where k is non-negative. For example:Giv ...
- python作业:模拟登陆(第一周)
模拟登陆作业需求: 1. 用户输入帐号密码进行登陆 2. 用户信息保存在文件内 3. 用户密码输入错误三次后锁定用户 额外实现功能: 1.提示输入错误次数 2.输入已锁定用户会提示 3.用户不存在会提 ...
- Vue 使用Spread.js没有层级关系(隐藏与显示)
Vue 使用Spread.js没有层级关系(隐藏与显示) 1.vue会给元素加一个监控属性.去掉 spread.js没有层级关系过半是column中值的问题
- BZOJ 1731: [Usaco2005 dec]Layout 排队布局
Description Like everyone else, cows like to stand close to their friends when queuing for feed. FJ ...
- 在Eclipse中调用weka包实现分类
1.如题. 最近写了一个FCM的聚类算法,希望能够可视化结果,因此一个想法是调用weka中的包,使自己的程序可以可视化.这里参考了网络上的方法,首先实现在Eclipse中调用weka包实现分类的功能. ...
- 一步步制作RPM包
一步步制作RPM包 来源 http://blog.51cto.com/laoguang/1103628 一.RPM制作步骤 我们在企业中有的软件基本都是编译的,我们每次安装都得编译,那怎么办呢?那就根 ...