Sequence

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 924    Accepted Submission(s): 499

Problem Description
Today we have a number sequence A includes n elements.
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.
 
Input
The first line contains a single integer T,indicating the number of test cases.
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

 
Output
For each case output one line,if the sequence is good ,output "Yes",otherwise output "No".
 
Sample Input
3
7
1 2 3 4 5 6 7
7
1 2 3 5 4 7 6
6
1 2 3 3 2 1
 
Sample Output
No
Yes
No
 
Source
 
题意:给一个串,如果这个串奇数位之和等于偶数位之和并且不是回文串输出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(水题)的更多相关文章

  1. HDU-1042-N!(Java大法好 &amp;&amp; HDU大数水题)

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Subm ...

  2. HDU 5391 水题。

    E - 5 Time Limit:1500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  3. hdu 1544 水题

    水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...

  4. HDU排序水题

    1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...

  5. hdu 2710 水题

    题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...

  6. Dijkstra算法---HDU 2544 水题(模板)

    /* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...

  7. hdu 5162(水题)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...

  8. hdu 3357 水题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...

  9. hdu 5038 水题 可是题意坑

    http://acm.hdu.edu.cn/showproblem.php?pid=5038 就是求个众数  这个范围小 所以一个数组存是否存在的状态即可了 可是这句话真恶心  If not all ...

随机推荐

  1. java程序——凯撒加密

    古罗马皇帝凯撒在打仗时曾经使用过以下方法加密军事情报: 请编写一个程序,使用上述算法加密或解密用户输入的英文字串要求设计思想.程序流程图.源代码.结果截图.   设计思想:输入一个字符串,然后将其中每 ...

  2. tp事务处理

    数据库事务处理见手册 逻辑事务处理 Model->startTrans(); // 开启事务 if(操作失败) { Model->rollback(); // 回滚 }else { Mod ...

  3. 从键盘输入数,输出它们的平方值&判断是不是2的阶次方数

    1.从键盘输入两个整数,然后输出它们的平方值和立方值 在Java中,没有像C语言那样有一个专供接受键盘输入值的scanf函数,所以一般的做法是从键盘输入一行字符,保存到字符串s中,再将字符组成的字符串 ...

  4. DesiredCapabilities的作用

    负责启动服务端时的参数设置,启动session的时候是必须提供的. Desired Capabilities本质上是key value的对象,它告诉appium server这样一些事情,比如: 本次 ...

  5. Mac 电脑鼠标和触摸板滚动方向不一致的问题【已解决】

    当我们使用鼠标连接到 MacBook 时,会发现无论怎么设置,鼠标和触摸板的滚动方向都是相反的,导致不能同时使用鼠标和触摸板 解决方法: 我安装了下面的程序,它只允许您反转鼠标的滚动行为: Scrol ...

  6. 放映PPT幻灯片演示文稿如何让演讲者备注不投影到屏幕上(转载)

    ps  files/ps.rar 放映PPT幻灯片演示文稿如何让演讲者备注不投影到屏幕上 如题,在PPT幻灯片的演示文稿中加入演讲者备注(使用PPT讲座时苦于有时会忘记一些要讲的数字,文字等),但是在 ...

  7. jQuery遍历 filter()方法

    实例 改变所有 div 的颜色,然后向类名为 "middle" 的类添加边框: $("div").css("background", &qu ...

  8. CentOS下创建和root权限完全相同用户

    新建用户 [root@bagon ~]# useradd newroot 修改密码 [root@bagon ~]# passwd newroot 编辑/etc/passwd,找到新建用户那一行 new ...

  9. intellij idea 2017 快捷键(提高工作效率)

    1.Shift+Enter Annotation annotation = c.getAnnotation(A.class); 这个时候你写代码的时候可能光标在c.getAnno中的某一个位置,那么你 ...

  10. 浅析_tmain() 与 main() 函数的区别

    _tmain()是为了支持Unicode所使用的main的一个别名,既然是别名,应该有宏定义过的,在<stdafx.h>里 #include <stdio.h> #indlud ...