CF1541B.Pleasant Pairs
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a1,a2,…,an consisting of n distinct integers. Count the number of pairs of indices (i,j) such that i<j and ai⋅aj=i+j .
输入格式
The first line contains one integer t ( 1≤t≤104 ) — the number of test cases. Then t cases follow.
The first line of each test case contains one integer n ( 2≤n≤105 ) — the length of array a .
The second line of each test case contains n space separated integers a1,a2,…,an ( 1≤ai≤2⋅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⋅105 .
输出格式
For each test case, output the number of pairs of indices (i,j) such that i<j and ai⋅aj=i+j .
输入输出样例
输入#1
3 2 3 1 3 6 1 5 5 3 1 5 9 2
输出#1
1 1 3
说明/提示
For the first test case, the only pair that satisfies the constraints is (1,2) , as a1⋅a2=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) .