HDU 5146 Sequence 判断序列不是回文 且奇数与偶数位的和不同
来源:互联网 发布:什么叫数据标签 编辑:程序博客网 时间:2024/05/20 02:21
Sequence
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 173 Accepted Submission(s): 126
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 thatAi≠Bi .
Now,give you the sequence A,check out it’s good or not.
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
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 integersA1,A2,…,An .
[Technical Specification]
1 <= T <= 100
1 <= n <= 1000
0 <=Ai <= 1000000
Each test case begins with a line contains an integer n,the length of sequence A.
The next line follows n integers
[Technical Specification]
1 <= T <= 100
1 <= n <= 1000
0 <=
Output
For each case output one line,if the sequence is good ,output "Yes",otherwise output "No".
Sample Input
371 2 3 4 5 6 771 2 3 5 4 7 661 2 3 3 2 1
Sample Output
NoYesNo
/*5146 判断序列不是回文 且奇数与偶数位的和不同 */#include<iostream>#include<stdio.h>using namespace std;int a[1001];int main(){int t,n,sum,i,j,f;scanf("%d",&t);while(t--){scanf("%d",&n);sum=0;for(i=0;i<n;i++){scanf("%d",&a[i]);if(i&1==1)sum+=a[i];elsesum-=a[i];}f=0;for(i=0,j=n-1;i<=j;i++,j--){if(a[i]!=a[j]){f=1;break;}}if(sum==0&&f==1)printf("Yes\n");elseprintf("No\n");}return 0;}
0 0
- HDU 5146 Sequence 判断序列不是回文 且奇数与偶数位的和不同
- 奇数和偶数的判断
- 二进制的偶数位与奇数位
- 一个数二进制序列中所有的偶数位和奇数位,分别输出二进制序列。
- C语言整数的二进制偶数位,奇数位和二进制序列的输出
- 判断奇数和偶数
- 判断奇数和偶数
- 输出一个数的二进制序列中的奇数位和偶数位
- 获取一个数二进制序列中所有的偶数位和奇数位
- C语言输出一个数二进制序列的奇数位和偶数位
- C语言 定义一个宏,用于交换一个二进制序列的奇数位和偶数位
- 获取一个数二进制序列中所有的偶数位和奇数位,并输出。
- 获取一个数二进制序列中所有的偶数位和奇数位,并输出
- 获取一个数二进制序列中所有的偶数位和奇数位,并输出。
- 调整数组顺序使得奇数位于偶数前面,且奇数与奇数,偶数与偶数之间的位置相对不变
- 使用位与运算,进行偶数 奇数判断
- 判断一个数是奇数还是偶数【按位与】
- 获取一个数二进制序列中所有的偶数位和奇数位,分别输出二进制序列。
- centos7最小化安装后如何设置出来ifconfig命令!
- VS之listview使用
- 更新贴图函数
- 处女男学Android(十一)---Gallery、ViewPager和ViewPager+Fragment实现的Tab导航
- Java输出字符串大小写字母个数【Java学习笔记】
- HDU 5146 Sequence 判断序列不是回文 且奇数与偶数位的和不同
- hdu 3065 病毒侵袭持续中(AC自动机)
- 简介JAVA IO
- 数组模拟队列
- 经典笔试题目
- HDU1285 确定比赛名次【拓扑排序】【优先队列】
- 非齐次方程组代码(C++)
- 【AngularJS系列2】scope - reeoo
- ACdreM-1061 郭式树 没文化真可怕