Sequence

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

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
 
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 1005
const int inf=0x7fffffff; //无限大
int a[maxn];
int main()
{
int n;
cin>>n;
while(n--)
{
//memset(a,0,sizeof(a));
int b;
scanf("%d",&b);
ll ans1=;
ll ans2=;
for(int i=;i<b;i++)
{
scanf("%d",&a[i]);
if(i%==)
ans1+=a[i];
else
ans2+=a[i];
}
if(ans1!=ans2)
cout<<"No"<<endl;
else
{
int flag=;
for(int i=;i<b;i++)
{
if(a[i]!=a[b-i-])
{
flag=;
break;
}
}
if(flag==)
cout<<"No"<<endl;
else
cout<<"Yes"<<endl;
}
}
return ;
}

bestcoder#23 1001 Sequence的更多相关文章

  1. bestcoder#23 1002 Sequence II 树状数组+DP

    Sequence II Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  2. BestCoder #47 1001&amp;&amp;1002

    [比赛链接]cid=608">clikc here~~ ps:真是wuyu~~做了两小时.A出两道题,最后由于没加longlong所有被别人hack掉!,最后竟然不知道hack别人不成 ...

  3. BestCoder #88(1001 1002)

    Find Q Accepts: 392 Submissions: 780 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/131 ...

  4. JZOJ 5922. sequence

    5922. [NOIP2018模拟10.23]sequence (File IO): input:sequence.in output:sequence.out Time Limits: 1000 m ...

  5. Akka-CQRS(7)- CQRS Reader Actor 示范

    我们在这篇通过一个具体CQRS-Reader-Actor的例子来示范akka-persistence的query端编程和应用.在前面的博客里我们设计了一个CQRS模式POS机程序的操作动作录入过程,并 ...

  6. hsql数据库使用详解(入门)及快速使用

    一.简介: hsql数据库是一款纯Java编写的免费数据库,许可是BSD-style的协议,如果你是使用Java编程的话,不凡考虑一下使用它,相对其 他数据库来说,其体积小,才563kb.仅一个hsq ...

  7. C语言结构体-struct

    知识点: 1)结构体的定义. 2)结构体的sizeof. 3)  结构体的指针. 1) 结构体的定义: 在逻辑上有一定关联的多个数据类型做为一整体进行操作的数据结构,它的关键字是struct.下面我将 ...

  8. Jinja2学习笔记暨官方文档的翻译

    http://blog.csdn.net/lgg201/article/details/4647471 呵呵, 刚刚看完Python模板引擎Jinja2的文档, 感觉很好, 觉得动态语言真是很好.  ...

  9. 【STM32H7教程】第8章 STM32H7的终极调试组件Event Recorder

    完整教程下载地址:http://forum.armfly.com/forum.php?mod=viewthread&tid=86980 第8章   STM32H7的终极调试组件Event Re ...

随机推荐

  1. java基础62 JavaScript中的函数(网页知识)

    1.JavaScript中,函数的格式 function 函数名(形参列表){ 函数体; } 2.JavaScript中,函数需要注意的细节 1.在javaScript中,函数定义形参时,是不能使用v ...

  2. Git系统学习网址

    https://code.csdn.net/help/CSDN_Code/progit/zh/07-customizing-git/01-chapter7

  3. MySQL学习笔记:delete from与truncate table的区别

    在Mysql数据库的使用过程中,删除表数据可以通过以下2种方式: delete from table_name truncate table table_name (1)delete from语句可以 ...

  4. Java模拟按键

    JDK自带了Robot类,此类用于为测试自动化.自运行演示程序和其他需要控制鼠标和键盘的应用程序生成本机系统输入事件.Robot 的主要目的是便于 Java 平台实现自动测试. 详情可查看jdk1.6 ...

  5. RabbitMQ系列之高可用集群

    为了实现高可用,我采用LVS+双节点RabbitMq , 架构图如下: 在RabbitMQ之前放了LVS, LVS 采用 rr 轮询算法 , 目的是将请求平均分配到两个真实节点,并配置5672端口监控 ...

  6. day7面向对象--进阶

    静态方法(@staticmethod)     通过@staticmethod装饰器即可把其装饰的方法变为一个静态方法,什么是静态方法呢?其实不难理解,普通的方法,可以在实例化后直接调用,并且在方法里 ...

  7. day2编写购物商城

    作业:购物商城 商品展示,价格 买,加入购物车 付款,钱不够 流程图如下: 代码共有4个文件,如下: 用户文件: alex geng zhang lou zeng 商品文件: 小米3 比亚迪宋 格力变 ...

  8. require.js 加载 vue组件 r.js 合并压缩

    https://www.taoquns.com 自己搭的个人博客 require.js 参考阮一峰 Javascript模块化编程(三):require.js的用法 r.js 合并压缩 参考司徒正美 ...

  9. 解决loadrunner 脚本和replaylog中的中文乱码问题

    解决loadrunner 脚本和replaylog中的中文乱码问题 解决这个问题必须认识到一个事实就是,loadrunner和测试服务器交换数据使用的是utf8格式,但是展现在replaylog中是使 ...

  10. 高仿360界面的实现(用纯XML和脚本实现)

    源码下载:360UI 本项目XML的桌面渲染依赖GQT开源项目(请感兴趣的朋友加入QQ讨论群:101189702,在群共享文件里下载GQT源码),以下是360界面实现的全部XML代码,所有的代码都在3 ...