hdu 5146(水题)
Sequence
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 924 Accepted Submission(s): 499
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<stdio.h>
#include<iostream>
#include<string.h>
#include <stdlib.h>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = ;
int n,a[N];
bool test1(){
LL sum1 = ,sum2 = ;
for(int i=;i<=n;i+=){
sum1+=a[i];
}
for(int i=;i<=n;i+=){
sum2+=a[i];
}
if(sum1==sum2) return true;
return false;
}
bool test2(){
for(int i=,j=n;i<j;i++,j--){
if(a[i]!=a[j]) return true;
}
return false;
}
int main()
{
int tcase;
scanf("%d",&tcase);
while(tcase--)
{
scanf("%d",&n);
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
}
if(test1()&&test2()) printf("Yes\n");
else printf("No\n");
}
return ;
}
hdu 5146(水题)的更多相关文章
- HDU-1042-N!(Java大法好 && HDU大数水题)
N! Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Subm ...
- HDU 5391 水题。
E - 5 Time Limit:1500MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- hdu 1544 水题
水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...
- HDU排序水题
1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...
- hdu 2710 水题
题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...
- Dijkstra算法---HDU 2544 水题(模板)
/* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...
- hdu 5162(水题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...
- hdu 3357 水题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...
- hdu 5038 水题 可是题意坑
http://acm.hdu.edu.cn/showproblem.php?pid=5038 就是求个众数 这个范围小 所以一个数组存是否存在的状态即可了 可是这句话真恶心 If not all ...
随机推荐
- 5-1 练习css 总结
1. 边框 border:3px dotted; border: 2px solid yellow; 背景颜色 background-color: red; 外攘 margin:20px 0 20px ...
- Android 导出traces.txt 遇到的坑
我一直以为traces.txt 导出需要root .因为每当我 cd data ll 然后就会告诉我 Permission denied 后来我问同事,怎么导出traces.txt 文件.同事说很简单 ...
- Trident学习笔记(一)
1. Trident入门 Trident ------------------- 三叉戟 storm高级抽象,支持有状态流处理: 好处是确保消费被处理一次: 以小批次方式处理输入流,得到精准一次性处理 ...
- Caliburn Micro Binding KeyDown Event
<TextBox x:Name="MyTextBox" TextAlignment="Left" FontSize="10" Widt ...
- Bit与Byte的区别
在工作中遇到一些概念模糊的地方, 需要记住了bit意为“位”或“比特”,是计算机运算的基础: byte意为“字节”,是计算机文件大小的基本计算单位: 说到usb2.0标准接口传输速率.许多人都将“48 ...
- [译]16-spring基于注解的配置元数据
从spring2.5起spring框架开始支持java注解的配置元数据.所以除了使用xml配置文件来描述bean的装配之外,你还 可以使用基于java注解的配置元数据来完成同样的功能. spring框 ...
- HTML--留
1.html图像 <p> 这是个图像<img src=“\路径\” alt=“图像不显示不出来时代替图片” width=“1” height=“1” > </p ...
- DataSource的设置
1.Centos和redhat,Fedora等版本无须设置,直接在cloud.cfg指定,默认是EC2 datasource_list: ['ConfigDrive','OpenStack'] 2.u ...
- JavaWeb笔记(四)Cookie&Session
Cookie 客户端会话技术,客户端保存,用于存储少量不太敏感的数据,在不登陆的情况下完成服务器对客户端的身份识别 简单使用步骤 创建Cookie对象,绑定数据 new Cookie(String n ...
- Linux学习前的准备
Linux学习前的准备 Linux的学习也是这次项目的一个点. 我的学习教材是 The Linux Command Line,这是本已经被翻译好了的 中英版本的教材,知识点还是比较入门的 我使用的是 ...