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. Linux Module框架【转】

    转自:http://www.cnblogs.com/LittleHann/p/4558719.html catalog 1. 概述 2. 使用模块 3. 插入和删除模块 4. 自动化与热插拔 5. 版 ...

  2. aarch64_g3

    glibc-langpack-wal-2.25-6.fc26.aarch64.rpm 2017-06-20 17:08 210K fedora Mirroring Project glibc-lang ...

  3. MVVM模式View和ViewModel的通信

    还需要些什么呢 在前面几篇博客中我们尝试去实现了MVVM中的数据绑定.命令绑定和事件绑定.貌似实现的差不多了.我最早尝试用MVVM去开发的时候也是这么想的,没有用第三方框架,甚至只是实现了数据绑定和命 ...

  4. MVC Ajax Form & Ajax Valida(笔记)

    1.引入必要的文件 <script src=.min.js")" type="text/javascript"></script> &l ...

  5. Python爬虫---requests库快速上手

    一.requests库简介 requests是Python的一个HTTP相关的库 requests安装: pip install requests 二.GET请求 import requests # ...

  6. weblogic更改端口

    两种方式: 1.访问console控制台页面,进入“环境\服务器\需要修改端口的服务器如AdminServer”,修改监听端口,保存并激活更改即可: 2.修改配置文件,进入weblogic的域目录,如 ...

  7. Vue 实现loading进度条

    项目中遇到的,用vue实现下: <template> <div class="plLoading"> <div class="plLoadi ...

  8. git —— 异常1,index.lock

    git提交过程中出现的问题 解决方法:找到 index.lock文件将其删除 一般 index.lock 在.git下面, 有时 .git 是隐藏的,但是无论怎样, 可以通过 everything 找 ...

  9. 洛谷P2279消防局的设立

    传送门啦 一个很摸不清头脑的树形dp 状态: $ dp[i][0] $ :选自己 $ dp[i][1] $ :选了至少一个儿子 $ dp[i][2] $ :选了至少一个孙子 ------------- ...

  10. 函数fgets和fputs、fread和fwrite用法小结(转)

    字符串读写函数fgets和fputs: 1.fgets()函数:原型char *fgets(char *s, int n, FILE *stream);从流中读取n-1(n默认1024)个字符之前,如 ...