• Managing Difficulties


     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 #define FOR(i,n,m) for(int i=n;i<=m;i++)
     4 //#define gc getchar()
     5 inline int read();static char buf[1000000],*pa=buf,*pb=buf;
     6 #define gc pa==pb&&(pb=(pa=buf)+fread(buf,1,1000000,stdin),pa==pb)?EOF:*pa++
     7 const int N=2010;
     8 int n,ct,ak,a[N];
     9 map<int,int> m;
    10 int main()
    11 {
    12     int t=read();FOR(i,1,t){
    13     m.clear();
    14     n=read();ct=0;
    15     FOR(i,0,n-1) a[i]=read();
    16     m[a[0]]=1;
    17     FOR(i,1,n-2)
    18     {
    19         FOR(j,i+1,n-1)
    20         {
    21             ak=2*a[i]-a[j];
    22             if(ak>=0 && m.count(ak)) ct+=m[ak];
    23         }
    24         ++m[a[i]];
    25     }
    26     printf("%d
    ",ct);
    27     }return 0;
    28 }
    29 
    30 
    31 inline int read()
    32 {
    33     register int x(0);register char c(gc);bool bbb=1;
    34     if(c=='-') {c=gc;}
    35     while(c<'0'||c>'9')c=gc;
    36     while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=gc;
    37     if(bbb)return x;
    38     else return -x;
    39 }
  • 相关阅读:
    [NOIP2015] D1T2 信息传递
    Codeforces #447 Div.2 Tutorial
    python进阶
    Vue入门
    python基础
    python介绍
    React笔记_(3)_react语法2
    React笔记_(2)_react语法1
    React笔记_(1)_react概述
    webpack笔记_(3)_First_Project
  • 原文地址:https://www.cnblogs.com/universeplayer/p/15308883.html
Copyright © 2020-2023  润新知