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\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的更多相关文章
- ICPC 2019-2020 North-Western Russia Regional Contest
目录 Contest Info Solutions Problem A. Accurate Movement Problem B. Bad Treap Problem E. Equidistant P ...
- 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 ...
- Managing IIS Log File Storage
Managing IIS Log File Storage You can manage the amount of server disk space that Internet Informa ...
- Managing the Lifecycle of a Service
service的生命周期,从它被创建开始,到它被销毁为止,可以有两条不同的路径: A started service 被开启的service通过其他组件调用 startService()被创建. 这种 ...
- Android内存管理(4)*官方教程 含「高效内存的16条策略」 Managing Your App's Memory
Managing Your App's Memory In this document How Android Manages Memory Sharing Memory Allocating and ...
- Managing Group Policy with PowerShell
Overview In this article, I’ll talk about your options when it comes to managing Group Policy using ...
- Managing Hierarchical Data in MySQL
Managing Hierarchical Data in MySQL Introduction Most users at one time or another have dealt with h ...
- [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 ...
- Managing linux Shell Jobs
Managing Shell Jobs When moving jobs between the foreground and background, it may be useful to ha ...
- Managing your Actor Systems
今天偶然得机会,找到一篇不错得文章,现在分享给大家. 原文:http://www.kotancode.com/2013/02/15/managing-your-actor-systems/ If yo ...
随机推荐
- markdown语法支持测试
latex 公式 \(v, w, \nu, \omega\) \[\iiint, \oiiint \] \(\Set{ x | x<\frac 1 2 }\) \(\displaystyle \ ...
- P3355 骑士共存问题题解
题目链接:P3355 骑士共存问题 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 题解: 棋盘问题考虑黑白染色成为二分图后做. 观察马的性质,可知一个点只能到一个异色点,所以,构造 ...
- SQL注入攻击及防御
SQL注入攻击及防御 1.项目实验环境 目标靶机OWASP_Broken_Web_App_VM_1.2: https://sourceforge.net/projects/owaspbwa/files ...
- 【论文阅读】IROS2017: Voxblox & RAL2019: Voxblox++
IROS2017: Voxblox & RAL2019: Voxblox++ Status: Finished Type: RAL Year: 2019 组织/Sensor: ETH-ASL ...
- Linux内存不够了?看看如何开启虚拟内存增加内存使用量
1.为什么要使用虚拟内存 当我们没有多余的钱去购买大内存的云服务器时,但是当前服务器里面的软件和程序运行的比较多导致内存不够用了.这个时候可以通过增加虚拟内存来扩大内存容量.但是在启用虚拟内存时,需要 ...
- css定位 position:sticky
今天在做css定位的时候遇到一个问题,我想用fixed定位下来,但是发现这个时候定义的百分百宽度不随着父元素走了而是整个屏幕的百分百,这个就很尴尬了,也不能固定宽度吧,毕竟还要宽度自适应. 这个时候发 ...
- msgpack的使用
1.引入包 <!--msgpack依赖--> <dependency> <groupId>org.msgpack</groupId> <artif ...
- 面试官:Dubbo一次RPC调用会经过哪些环节?
大家好,我是三友~~ 今天继续探秘系列,扒一扒一次RPC请求在Dubbo中经历的核心流程. 本文是基于Dubbo3.x版本进行讲解 一个简单的Demo 这里还是老样子,为了保证文章的完整性和连贯性,方 ...
- window10设置开机自启动exe的三种方式(亲测有效)
拷贝文件到自启动位置 路径地址:C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp 通过组策略设置脚本随服务器启动 开始-> ...
- jQuery中hide()和display的区别在于它们实现元素隐藏的方式不同。
1. hide()方法是jQuery提供的一个函数,用于隐藏元素.当使用hide()方法时,元素会被设置为display:none,即不显示在页面上,但仍然占据着原来的空间.隐藏后的元素可以通过调用s ...