menu ZJOJ
account_circle 请登录
home
首页
book
题目
apps
分类
play_circle_outline
状态
assessment
竞赛
assignment
作业
equalizer
排名
assignment_ind
登录
person_add
注册
1549: A-B Problem
时间限制:2.000s
内存限制:128MB

题目描述

你已经能够轻松地解决 lns="http://www.w3.org/1998/Math/MathML">A+B 问题了,那一定也能做出这道 lns="http://www.w3.org/1998/Math/MathML">A - B 问题吧!

给定一个大小为 lns="http://www.w3.org/1998/Math/MathML">n 的正整数序列 lns="http://www.w3.org/1998/Math/MathML">a,和一个正整数 lns="http://www.w3.org/1998/Math/MathML">C,你需要计算出符合条件 lns="http://www.w3.org/1998/Math/MathML">a_i - a_j = C 的数对 lns="http://www.w3.org/1998/Math/MathML">(a_i,a_j) 个数,其中 lns="http://www.w3.org/1998/Math/MathML">1 \le i,j \le n

两个数对 lns="http://www.w3.org/1998/Math/MathML">(a_{i1},a_{j1})lns="http://www.w3.org/1998/Math/MathML">(a_{i2},a_{j2}) 被认为是不同的,当且仅当 lns="http://www.w3.org/1998/Math/MathML">i1 \ne i2\ or\ j1 \ne\ j2,其中 lns="http://www.w3.org/1998/Math/MathML">1 \le i1,i2,j1,j2 \le n

输入格式

第一行:两个正整数 lns="http://www.w3.org/1998/Math/MathML">n,C

第二行:lns="http://www.w3.org/1998/Math/MathML">n 个正整数,表示 lns="http://www.w3.org/1998/Math/MathML">a_1,a_2,···,a_n

数据范围:lns="http://www.w3.org/1998/Math/MathML">1 \le n \le 2 \times 10^5lns="http://www.w3.org/1998/Math/MathML">1 \le C \le 10^9lns="http://www.w3.org/1998/Math/MathML">1 \le a_i \le 10^9lns="http://www.w3.org/1998/Math/MathML">1 \le i \le n)。

输出格式

一个整数,表示符合条件的数对个数。

样例输入 content_copy

5 2
1 1 2 3 0

样例输出 content_copy

3