CF1541B.Pleasant Pairs

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an array a1,a2,,ana_1, a_2, \dots, a_n consisting of nn distinct integers. Count the number of pairs of indices (i,j)(i, j) such that i<ji < j and aiaj=i+ja_i \cdot a_j = i + j .

输入格式

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

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

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

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

输出格式

For each test case, output the number of pairs of indices (i,j)(i, j) such that i<ji < j and aiaj=i+ja_i \cdot a_j = 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)(1, 2) , as a1a2=1+2=3a_1 \cdot a_2 = 1 + 2 = 3

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

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

首页