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 ;
}
上一篇:DataGuard---->主库和备库都配置 db_file_name_convert和log_file_name_convert的作用


下一篇:ArcEngine 不能再打开其他表了