• bestcoder#23 1001 Sequence


    Sequence


    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 712    Accepted Submission(s): 439


    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 that AiBi.
    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 A1,A2,,An.

    [Technical Specification]
    1 <= T <= 100
    1 <= n <= 1000
    0 <= Ai <= 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 <cstdio>
    #include <cmath>
    #include <cstring>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <set>
    #include <vector>
    #include <sstream>
    #include <queue>
    #include <typeinfo>
    #include <fstream>
    typedef long long ll;
    using namespace std;
    //freopen("D.in","r",stdin);
    //freopen("D.out","w",stdout);
    #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
    #define maxn 1005
    const int inf=0x7fffffff;   //无限大
    int a[maxn];
    int main()
    {
        int n;
        cin>>n;
        while(n--)
        {
            //memset(a,0,sizeof(a));
            int b;
            scanf("%d",&b);
            ll ans1=0;
            ll ans2=0;
            for(int i=0;i<b;i++)
            {
                scanf("%d",&a[i]);
                if(i%2==0)
                    ans1+=a[i];
                else
                    ans2+=a[i];
            }
            if(ans1!=ans2)
                cout<<"No"<<endl;
            else
            {
                int flag=0;
                for(int i=0;i<b;i++)
                {
                    if(a[i]!=a[b-i-1])
                    {
                        flag=1;
                        break;
                    }
                }
                if(flag==0)
                    cout<<"No"<<endl;
                else
                    cout<<"Yes"<<endl;
            }
        }
        return 0;
    }
  • 相关阅读:
    微信公众平台接口测试账号申请
    Windows平台下tomcat+java的web程序持续占cpu问题调试
    mysql存储过程基础
    Mysql权限控制
    MySQL开启federated引擎实现数据库表映射
    JAVA中Set集合--HashSet的使用
    在js中嵌套java代码
    MySql计算两个日期的时间差函数
    关于easyui combobox下拉框实现多选框的实现
    利用excel办公软件快速拼凑sql语句
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4176205.html
Copyright © 2020-2023  润新知