Codeforces Round 728 (Div. 2)
B
Pleasant Pairs
Codeforces
1200
原题
← AC →
翻译中…

You are given an array $a_1, a_2, \dots, a_n$ consisting of $n$ distinct integers. Count the number of pairs of indices $(i, j)$ such that $i \lt j$ and $a_i \cdot a_j = i + j$.

翻译中…

Input

翻译中…

The first line contains one integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. Then $t$ cases follow.

翻译中…

The first line of each test case contains one integer $n$ ($2 \leq n \leq 10^5$) — the length of array $a$.

翻译中…

The second line of each test case contains $n$ space separated integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq 2 \cdot n$) — the array $a$. It is guaranteed that all elements are distinct.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.

翻译中…

Output

翻译中…

For each test case, output the number of pairs of indices $(i, j)$ such that $i \lt j$ and $a_i \cdot a_j = i + j$.

翻译中…

Note

翻译中…

For the first test case, the only pair that satisfies the constraints is $(1, 2)$, as $a_1 \cdot a_2 = 1 + 2 = 3$

翻译中…

For the second test case, the only pair that satisfies the constraints is $(2, 3)$.

翻译中…

For the third test case, the pairs that satisfy the constraints are $(1, 2)$, $(1, 5)$, and $(2, 3)$.

翻译中…

样例

Input #1
3
2
3 1
3
6 1 5
5
3 1 5 9 2
Output #1
1
1
3
InputCopy OutputCopy
题目信息
题号
1541B
时间限制
2 s
内存限制
256 MB
标签
暴力
模拟
数学
数论

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