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\n",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 }

Managing Difficulties的更多相关文章

  1. ICPC 2019-2020 North-Western Russia Regional Contest

    目录 Contest Info Solutions Problem A. Accurate Movement Problem B. Bad Treap Problem E. Equidistant P ...

  2. Managing a node remotely by using the netapp SP

    Managing a node remotely by using the Service Processor The Service Processor (SP) is a remote manag ...

  3. Managing IIS Log File Storage

    Managing IIS Log File Storage   You can manage the amount of server disk space that Internet Informa ...

  4. Managing the Lifecycle of a Service

    service的生命周期,从它被创建开始,到它被销毁为止,可以有两条不同的路径: A started service 被开启的service通过其他组件调用 startService()被创建. 这种 ...

  5. Android内存管理(4)*官方教程 含「高效内存的16条策略」 Managing Your App's Memory

    Managing Your App's Memory In this document How Android Manages Memory Sharing Memory Allocating and ...

  6. Managing Group Policy with PowerShell

    Overview In this article, I’ll talk about your options when it comes to managing Group Policy using ...

  7. Managing Hierarchical Data in MySQL

    Managing Hierarchical Data in MySQL Introduction Most users at one time or another have dealt with h ...

  8. [Angular 2] Managing State in RxJS with StartWith and Scan

    The scan operator in RxJS is the main key to managing values and states in your stream. Scan behaves ...

  9. Managing linux Shell Jobs

    Managing Shell Jobs   When moving jobs between the foreground and background, it may be useful to ha ...

  10. Managing your Actor Systems

    今天偶然得机会,找到一篇不错得文章,现在分享给大家. 原文:http://www.kotancode.com/2013/02/15/managing-your-actor-systems/ If yo ...

随机推荐

  1. python重拾第十一天-REDIS缓存数据库

    缓存数据库介绍 NoSQL(NoSQL = Not Only SQL ),意即"不仅仅是SQL",泛指非关系型的数据库,随着互联网web2.0网站的兴起,传统的关系数据库在应付we ...

  2. Linux 内核:设备树(2)dtb转换成device_node

    Linux 内核:设备树(2)dtb转换成device_node 背景 前面我们了解到dtb的内存分布以后(dtb格式),接下来就来看看内核是如何把设备树解析成所需的device_node. 原文(有 ...

  3. docker部署微服务之注册中心

    1.首先要对对应服务的pom.xml文件进行修改,添加如下配置. 2.在微服务的pom.xml目录下建立Dockerfile文件 3.在Dockerfile当前目录下执行mvn clean insta ...

  4. 嵌入式工业开发板基础测试手册——基于NXP iMX6ULL开发板(1)

    前 言 本文档适用开发环境: Windows开发环境:Windows 7 64bit.Windows 10 64bit 虚拟机:VMware15.1.0 Linux开发环境:Ubuntu18.04.4 ...

  5. .Net Core 全局捕获异常-中间件

    1.代码版本 .Net Core 版本 2.2 2.目录结构 3.定义中间件 新建一个类 CustomerExceptionMiddleware.cs /// <summary> /// ...

  6. HBase 在统一内容平台业务的优化实践

    作者:来自 vivo 互联网服务器团队-Leng Jianyu.Huang Haitao HBase是一款开源高可靠性.扩展性.高性能和灵活性的分布式非关系型数据库,本文围绕数据库选型以及使用HBas ...

  7. 机器学习策略篇:详解处理数据不匹配问题(Addressing data mismatch)

    处理数据不匹配问题 如果您的训练集来自和开发测试集不同的分布,如果错误分析显示有一个数据不匹配的问题该怎么办?这个问题没有完全系统的解决方案,但可以看看一些可以尝试的事情.如果发现有严重的数据不匹配问 ...

  8. 登录到第一级终端后,如果再次ssh登录到其他终端,SecureCRT标签变更的问题

    "终端->仿真->高级",勾选"忽略窗口标题更改请求"

  9. 【Git】04 文件删除

    版本分支的概念提示: 工作区就是我们的Git本地仓库,也就是一个很普通的目录 . 通过ADD指令添加文件到暂存区中, 在通过COMMIT指令提交到版本分支, 所谓的版本分支,就是就是这个蓝色的Mast ...

  10. 个人自家使用的路由器:水星D121G —— 1200M 11AC双频千兆无线路由器 D121G

    地址: https://www.mercurycom.com.cn/product-465-0.html