题目连接

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

手速题。。。

  1. #include<algorithm>
  2. #include<iostream>
  3. #include<cstdlib>
  4. #include<cstring>
  5. #include<cstdio>
  6. #include<vector>
  7. #include<map>
  8. #include<set>
  9. using std::cin;
  10. using std::cout;
  11. using std::endl;
  12. using std::find;
  13. using std::sort;
  14. using std::set;
  15. using std::map;
  16. using std::pair;
  17. using std::vector;
  18. using std::multiset;
  19. using std::multimap;
  20. #define pb(e) push_back(e)
  21. #define sz(c) (int)(c).size()
  22. #define mp(a, b) make_pair(a, b)
  23. #define all(c) (c).begin(), (c).end()
  24. #define iter(c) decltype((c).begin())
  25. #define cls(arr,val) memset(arr,val,sizeof(arr))
  26. #define cpresent(c, e) (find(all(c), (e)) != (c).end())
  27. #define rep(i, n) for (int i = 1; i <= (int)(n); i++)
  28. #define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
  29. const int Max_N = ;
  30. typedef unsigned long long ull;
  31. int arr[Max_N];
  32. int main() {
  33. #ifdef LOCAL
  34. freopen("in.txt", "r", stdin);
  35. freopen("out.txt", "w+", stdout);
  36. #endif
  37. int t, n;
  38. ull sum1, sum2;
  39. scanf("%d", &t);
  40. while (t--) {
  41. bool f = false;
  42. sum1 = sum2 = ;
  43. scanf("%d", &n);
  44. rep(i, n) {
  45. scanf("%d", &arr[i]);
  46. if (i & ) sum1 += arr[i];
  47. else sum2 += arr[i];
  48. }
  49. if (sum1 != sum2) { puts("No"); continue; }
  50. for (int i = , j = n; i < j; i++, j--) {
  51. if (arr[i] != arr[j]) { f = true; break; }
  52. }
  53. puts(f ? "Yes" : "No");
  54. }
  55. return ;
  56. }

hdu 5146 Sequence的更多相关文章

  1. 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变 ...

  2. HDU 5919 Sequence II(主席树+逆序思想)

    Sequence II Time Limit: 9000/4500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) To ...

  3. HDU 6395 Sequence 【矩阵快速幂 && 暴力】

    任意门:http://acm.hdu.edu.cn/showproblem.php?pid=6395 Sequence Time Limit: 4000/2000 MS (Java/Others)   ...

  4. hdu 5312 Sequence(数学推导——三角形数)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5312 Sequence Time Limit: 2000/2000 MS (Java/Others)  ...

  5. hdu 1711Number Sequence (KMP入门,子串第一次出现的位置)

    Number Sequence Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  6. hdu 3397 Sequence operation(线段树:区间更新)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3397 题意:给你一个长度为n的0,1序列,支持下列五种操作, 操作0(0 a b):将a到b这个区间的 ...

  7. HDU 1141---Brackets Sequence(区间DP)

    题目链接 http://poj.org/problem?id=1141 Description Let us define a regular brackets sequence in the fol ...

  8. hdu 1711Number Sequence

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1711 数字KMP,原来还能这么用 #include<stdio.h> ],b[]; ]; ...

  9. 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 ...

随机推荐

  1. 怎样去掉FireFox的导入向导

    用robotframework的时候,用ride去打开firefox,但是每次都会出现导入向导,影响了后续的操作,怎样才能去掉呢? 网上查到的解决方案是:到firefox的profiles.ini所在 ...

  2. WebView 获取网页点击事件

    网页上的点击按钮 本身绑定了URL,点击的时候webview 会在下面的这个方法中加载URL - (BOOL)webView:(UIWebView*)webView shouldStartLoadWi ...

  3. mybatis-generator 代码自动生成工具

    今天来介绍下怎么用mybatis-gennerator插件自动生成mybatis所需要的dao.bean.mapper xml文件,这样我们可以节省一部分精力,把精力放在业务逻辑上. 之前看过很多文章 ...

  4. TCP/IP详解学习笔记(10)-- DNS:域名系统

    1.DNS      DNS 是计算机域名系统(Domain Name System 或Domain Name Service) 的缩写,它是由解析器以及域名服务器组成的.域名服务器是指保存有该网络中 ...

  5. java基础回顾(五)——Stack、Heap

    栈(stack):是简单的数据结构,但在计算机中使用广泛.栈最显著的特征是:LIFO(Last In, First Out,后进先出).比如我们往箱子里面放衣服,先放入的在最下方,只有拿出后来放入的才 ...

  6. ASP.NET的SEO:使用.ashx文件——排除重复内容

    本系列目录 不同的链接指向的页面如果具有大量相同的内容,这种现象就会被称为"重复内容",如果一个网站的重复内容很多,搜索引擎就会认为这个网站的价值不高.所以我们应尽量避免各种重复内 ...

  7. SID与GUID的区别

    1.在AD里面创建一个用户或者组都会为其分配一个SID,同时也会为这些对象分配一个GUID,GUID是一个128位的字符串,一个标识符,GUID不仅在整个域里面是唯一的,并且在全世界的范围内都是唯一的 ...

  8. 【好文要转】Python:模拟登录以获取新浪微博OAuth的code参数值

    [转自]http://www.tuicool.com/articles/zAz6zi [原文]http://blog.segmentfault.com/hongfei/1190000000343851 ...

  9. JavaScript编程规范

    最近看NodeJS中,有一部分写JS约定俗成的编程规范(附录B,详情参考附件),感觉在实际工作中能用到, 大致意思分享给大家,详情参考附件: 1.缩进:建议两空格 作为Node.js代码的缩进标记: ...

  10. c++ 创建 socket server

    下面一段代码是创建socket server的代码片段: 需要引用的库包括: #include <sys/types.h> #include <sys/socket.h> #i ...