Codeforces Round 1079 (Div. 1)
B
Another Problem about Beautiful Pairs
Codeforces
1600
原题
← AC1 →
翻译中…

In the array $a$, we call a pair of indices $i$, $j$ beautiful if the following condition holds:

翻译中…
  • $a_{i} \cdot a_{j} = j - i$.
翻译中…

Count the number of beautiful pairs in the array $a$.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line of each test case contains a single integer $n$ ($2 \le n \le 2 \cdot 10^{5}$).

翻译中…

The second line of each test case contains $n$ integers $a_{i}$ ($1 \le a_{i} \le 10^{9}$).

翻译中…

Additional constraints on the input:

翻译中…
  • The sum of $n$ across all test cases does not exceed $2 \cdot 10^5$.
翻译中…

Output

翻译中…

For each test case, output a single integer — the answer to the problem.

翻译中…

Note

翻译中…

In the first example, there are $3$ beautiful pairs: ($1, 2$), ($1, 3$), and ($1, 5$).

翻译中…

In the second example, there are $7$ beautiful pairs: ($1, 3$), ($1, 5$), ($2, 4$), ($2, 6$), ($3, 4$), ($3, 5$), and ($4, 6$).

翻译中…

样例

Input #1
4
5
1 1 2 100 4
6
2 2 1 1 2 2
10
1 1 2 3 4 1 1 7 3 9
2
1000000000 1000000000
Output #1
3
7
10
0
InputCopy OutputCopy
题目信息
题号
2196B
时间限制
2 s
内存限制
256 MB
标签
暴力
数学
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。