P1102 A - B Pairs
Background
出题是一件痛苦的事情!
相同的题目看多了也会有审美疲劳,于是我舍弃了大家所熟悉的 A+B Problem,改用 A-B 了哈哈!
Description
Given a sequence of positive integers and a positive integer $C$, compute the number of pairs $(A, B)$ such that $A - B = C$. Pairs with the same values at different positions are considered distinct.
Input Format
The input consists of two lines.
The first line contains two positive integers $N, C$.
The second line contains $N$ positive integers, which form the sequence to be processed.
Output Format
Output one line containing the number of pairs in the sequence that satisfy $A - B = C$.
Explanation/Hint
Constraints:
- For $75\%$ of the testdata, $1 \leq N \leq 2000$.
- For $100\%$ of the testdata, $1 \leq N \leq 2 \times 10^5$, $0 \leq a_i < 2^{30}$, $1 \leq C < 2^{30}$.
Two new testdata sets were added on 2017/4/29.
Translated by ChatGPT 5