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 ...
随机推荐
- helloworld - 程序员的第一个社区终于来了
helloworld - 程序员的第一个社区终于来了 csdn事件 CSDN旗下的GitCode最近因为一种极其不道德的行为引起了开发者的广泛愤怒和抗议.CSDN在没有通知或征求开发者同意的情况下,悄 ...
- 【Zabbix】Zabbix5.0安装部署问题汇总
报错信息:No package 'oniguruma' found 解决方法:https://www.limstash.com/articles/202003/1563 报错信息: PHP bcmat ...
- Vue Element-UI 按需引入提示Cannot find module 'babel-preset-es2015'
1.我的开发环境和操作步骤 1.1.使用VUE-CLI创建 2.x 脚手架 1.2.安装 npm i element-ui(参照官网) 1.3.安装 npm install babel-plugin ...
- yb课堂之登陆校验Json Web Token实战之封装通用方法 《九》
引入相关依赖并开发JWT工具类,开发生产token和校验token的方法 加入相关依赖 <dependency> <groupId>io.jsonwebtoken</gr ...
- windows服务开发demo
0.写在前面 windows7开始,windows服务运行在session 0, 用户程序都运行在session x (x >= 1) 而session之间是有隔离的,实践发现是无法在服务中直接 ...
- 精品 IDEA 插件大汇总!值得收藏
轻松提高 Java 开发效率 俗话说,工欲善其事,必先利其器.想要提升编程开发效率,必须选择一款顺手的开发工具. 对于 Java 开发者,JetBrains IDEA 无疑是目前最主流的开发工具,既简 ...
- [oeasy]python0015_键盘改造_将esc和capslock对调_hjkl_移动_双手正位
键盘改造 回忆上次内容 上次练习了复制粘贴 按键 作用 <kbd>y</kbd><kbd>y</kbd> 复制光标行代码 到剪贴板 <kbd> ...
- C#:利用“事务+乐观锁+version”解决并发下的数据一致性问题
本文重点介绍通过事务控制,利用数据库的乐观锁和时间戳,来解决并发(非高并发)环境下的脏读.幻读.不可重复读等问题,同时也能解决超卖等现象,对开发企业管理系统的朋友提供一个思路,为更突出主题思路,文涉及 ...
- 题解:CF1971C Clock and Strings
题解:CF1971C Clock and Strings 题意 在上图的一个圆中,给予你四个点 \(a,b,c,d\),判断线段 \(ab\) 与线段 \(cd\) 是否相交. 思路 先设置一个字符串 ...
- Python threading实现多线程 提高篇 线程同步,以及各种锁
本文主要讲多线程的线程之间的资源共享怎么保持同步. 多线程基础篇见,Python threading实现多线程 基础篇 Python的多线程,只有用于I/O密集型程序时效率才会有明显的提高,如文件/输 ...