• 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} eq 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 = 1010;
    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 = 0;
    43         scanf("%d", &n);
    44         rep(i, n) {
    45             scanf("%d", &arr[i]);
    46             if (i & 1) sum1 += arr[i];
    47             else sum2 += arr[i];
    48         }
    49         if (sum1 != sum2) { puts("No"); continue; }
    50         for (int i = 1, j = n; i < j; i++, j--) {
    51             if (arr[i] != arr[j]) { f = true; break; }
    52         }
    53         puts(f ? "Yes" : "No");
    54     }
    55     return 0;
    56 }
    View Code
    By: GadyPu 博客地址:http://www.cnblogs.com/GadyPu/ 转载请说明
  • 相关阅读:
    resultMap之collection聚集
    try{}catch{}finally{}使用总结
    动手动脑兼课后作业2
    第一个psp0级
    原码反码补码
    动手动脑兼课后作业
    第七周进度报告
    第六周进度报告
    第五周进度报告
    《大道至简》读后感
  • 原文地址:https://www.cnblogs.com/GadyPu/p/4608207.html
Copyright © 2020-2023  润新知