hdu 5146 Sequence
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5146
Sequence
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 $A_{i}\neq B_{i}.$
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 $A_{1},A_{2}, \ldots, A_{n}$
[Technical Specification]
1 <= T <= 100
1 <= n <= 1000
0 <= $A_{i}$ <= 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<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
using std::cin;
using std::cout;
using std::endl;
using std::find;
using std::sort;
using std::set;
using std::map;
using std::pair;
using std::vector;
using std::multiset;
using std::multimap;
#define pb(e) push_back(e)
#define sz(c) (int)(c).size()
#define mp(a, b) make_pair(a, b)
#define all(c) (c).begin(), (c).end()
#define iter(c) decltype((c).begin())
#define cls(arr,val) memset(arr,val,sizeof(arr))
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
const int Max_N = ;
typedef unsigned long long ull;
int arr[Max_N];
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
int t, n;
ull sum1, sum2;
scanf("%d", &t);
while (t--) {
bool f = false;
sum1 = sum2 = ;
scanf("%d", &n);
rep(i, n) {
scanf("%d", &arr[i]);
if (i & ) sum1 += arr[i];
else sum2 += arr[i];
}
if (sum1 != sum2) { puts("No"); continue; }
for (int i = , j = n; i < j; i++, j--) {
if (arr[i] != arr[j]) { f = true; break; }
}
puts(f ? "Yes" : "No");
}
return ;
}
hdu 5146 Sequence的更多相关文章
- HDU 3397 Sequence operation(线段树)
HDU 3397 Sequence operation 题目链接 题意:给定一个01序列,有5种操作 0 a b [a.b]区间置为0 1 a b [a,b]区间置为1 2 a b [a,b]区间0变 ...
- HDU 5919 Sequence II(主席树+逆序思想)
Sequence II Time Limit: 9000/4500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) To ...
- HDU 6395 Sequence 【矩阵快速幂 && 暴力】
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=6395 Sequence Time Limit: 4000/2000 MS (Java/Others) ...
- hdu 5312 Sequence(数学推导——三角形数)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5312 Sequence Time Limit: 2000/2000 MS (Java/Others) ...
- hdu 1711Number Sequence (KMP入门,子串第一次出现的位置)
Number Sequence Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu 3397 Sequence operation(线段树:区间更新)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3397 题意:给你一个长度为n的0,1序列,支持下列五种操作, 操作0(0 a b):将a到b这个区间的 ...
- HDU 1141---Brackets Sequence(区间DP)
题目链接 http://poj.org/problem?id=1141 Description Let us define a regular brackets sequence in the fol ...
- hdu 1711Number Sequence
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1711 数字KMP,原来还能这么用 #include<stdio.h> ],b[]; ]; ...
- HDU 5918 Sequence I KMP
Sequence I Problem Description Mr. Frog has two sequences a1,a2,⋯,an and b1,b2,⋯,bm and a number p ...
随机推荐
- Flex4/Flash开发在线音乐播放器 , 含演示地址
要求 必备知识 本文要求基本了解 Adobe Flex编程知识和JAVA基础知识. 开发环境 MyEclipse10/Flash Builder4.6/Flash Player11及以上 演示地址 演 ...
- 断言--NSAssert
NSAssert()是一个宏,用于开发阶段调试程序中的Bug,通过为NSAssert()传递条件表达式来断定是否属于Bug,满足条件返回真值,程序继续运行,如果返回假值,则抛出异常,并切可以自定义异常 ...
- EXTJS 6 新特性(译文)
Extjs 新特性 简介 使用extjs,sencha 团队开发一个简单的框架,可以为创建在任何类型设备上运行的应用,从手机端到平板电脑再到桌面应用,你将能够产生最佳的用户体验,编写更少的代码量,结合 ...
- TCP/IP详解学习笔记(1)-- 概述
1.TCP/IP的分层结构 网络协议通常分不同层次进行开发,每一层分别负责不同的同信功能.TCP/IP通常被认为是一个四层协议系统. 如图所示. 1)链路层(数据链路层 ...
- Android SharedPreferences 见解
今天突然遇到了SharedPreferences问题,虽然以前用过,但从没有深入的了解一下,今天就顺便深入了解一下,并总结一下,防止以后忘记. SharePreferences是Android平台上一 ...
- Landsat 8 OLI_TIRS 卫星数字产品
产品描述 2013 年2月11日,美国航空航天局(NASA) 成功发射Landsat-8卫星.Landsat-8卫星上携带两个传感器,分别是OLI陆地成像仪(Operation ...
- poj2017
一天两个题,凑数用的大水题啊...不解释了..羞愧ing #include <stdio.h> int main(){ int t; int i; ],b[],tot; ){ tot=; ...
- Android:控件布局(表格布局)TableLayout
TableLayout继承LinearLayout 实例:用表格布局实现计算机布局>>>>>>>>>>>> 有多少个TableR ...
- 【风马一族_php】NO0_搭建web服务器
原文来自:http://www.cnblogs.com/sows/p/5977996.html (博客园的)风马一族 侵犯版本,后果自负 安装apache apache是一种B/S结构的软件,apa ...
- Hub control
Hub(中心) 中心页是用户进入应用的入口点.中心页在丰富的平移视图中显示内容,这样用户一眼就能看见新鲜有趣的内容,从而吸引他们深入了解你的应用中的更多内容.中心显示不同的内容类别,每个类别映射到应用 ...