bestcoder#23 1001 Sequence
Sequence
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 712 Accepted Submission(s): 439
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 <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的更多相关文章
- bestcoder#23 1002 Sequence II 树状数组+DP
Sequence II Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- BestCoder #47 1001&&1002
[比赛链接]cid=608">clikc here~~ ps:真是wuyu~~做了两小时.A出两道题,最后由于没加longlong所有被别人hack掉!,最后竟然不知道hack别人不成 ...
- BestCoder #88(1001 1002)
Find Q Accepts: 392 Submissions: 780 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/131 ...
- JZOJ 5922. sequence
5922. [NOIP2018模拟10.23]sequence (File IO): input:sequence.in output:sequence.out Time Limits: 1000 m ...
- Akka-CQRS(7)- CQRS Reader Actor 示范
我们在这篇通过一个具体CQRS-Reader-Actor的例子来示范akka-persistence的query端编程和应用.在前面的博客里我们设计了一个CQRS模式POS机程序的操作动作录入过程,并 ...
- hsql数据库使用详解(入门)及快速使用
一.简介: hsql数据库是一款纯Java编写的免费数据库,许可是BSD-style的协议,如果你是使用Java编程的话,不凡考虑一下使用它,相对其 他数据库来说,其体积小,才563kb.仅一个hsq ...
- C语言结构体-struct
知识点: 1)结构体的定义. 2)结构体的sizeof. 3) 结构体的指针. 1) 结构体的定义: 在逻辑上有一定关联的多个数据类型做为一整体进行操作的数据结构,它的关键字是struct.下面我将 ...
- Jinja2学习笔记暨官方文档的翻译
http://blog.csdn.net/lgg201/article/details/4647471 呵呵, 刚刚看完Python模板引擎Jinja2的文档, 感觉很好, 觉得动态语言真是很好. ...
- 【STM32H7教程】第8章 STM32H7的终极调试组件Event Recorder
完整教程下载地址:http://forum.armfly.com/forum.php?mod=viewthread&tid=86980 第8章 STM32H7的终极调试组件Event Re ...
随机推荐
- 转 Java的 BigDecimal类型比较大小
这个类是java里精确计算的类 1.比较对象是否相等,一般的对象用equals,但是BigDecimal比较特殊,举个例子 BigDecimal a = new BigDecimal.valueOf( ...
- 在jsp页面中设置了远程验证,在初始化时必须预先调用一次。
参考链接:http://code.taobao.org/p/sztaotao/diff/5/trunk/code/src/main/webapp/webpage/modules/sys/roleFor ...
- Django 2.0.3安装-压缩包方式
OS:Windows 10家庭中文版,CPU:Intel Core i5-8250U Python版本:Python 2.7,Python 3.6 Django版本:2.0.3(最新2.0.5) 解压 ...
- 如何从TFS(Visual Studio Team Foundation Server)映射下载本地文件夹
1.连接tfs项目 首先打开vs2017 ——>工具栏 中的 团队——> 选择团队的管理链接 2.选择管理工作区 显示管理工作区的弹窗,点击 编辑 显示弹窗,选择本地文件夹(即要保存 ...
- 洛谷P1177快速排序
传送门 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> ...
- thinkphp模型创建
- ubuntu12.04安装ruby2.3
为了搭建github-pages博客,而github-pages后端依赖于ruby,且对版本有严格要求,自己尝试了各种姿势升级ruby2.3无果,最终在查阅了各种资料之后找到一个可行方案. icebu ...
- DevExpress 去除皮肤的方法
我从不用皮肤,方法如下:
- IntelliJ IDEA + Tomcat 部署问题
首先要了解下 tomcat的 几种部署方式(大致分为静态部署和动态部署),可以百度,博客:http://qsfwy.iteye.com/blog/466461 IntelliJ IDEA 下部署项目的 ...
- C#基础系列 - 抽象类及其方法的学习
在C#中使用关键字 abstract 来定义抽象类和抽象方法. 不能初始化的类被叫做抽象类,它们只提供部分实现,但是另一个类可以继承它并且能创建它们的实例. "一个包含一个或多个纯虚函数的类 ...