CF2196B.Another Problem about Beautiful Pairs

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

In the array aa, we call a pair of indices ii, jj beautiful if the following condition holds:

  • ai⋅aj=j−ia_{i} \cdot a_{j} = j - i.

Count the number of beautiful pairs in the array aa.

在数组 aa 中,若下标对 ii、jj 满足以下条件,则称其为优美对:

  • ai⋅aj=j−ia_{i} \cdot a_{j} = j - i。

请计算数组 aa 中优美对的个数。

输入格式

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

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

The second line of each test case contains nn integers aia_{i} (1≤ai≤1091 \le a_{i} \le 10^{9}).

Additional constraints on the input:

  • The sum of nn across all test cases does not exceed 2⋅1052 \cdot 10^5.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1041 \le t \le 10^4)。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(2≤n≤2⋅1052 \le n \le 2 \cdot 10^{5})。

每个测试用例的第二行包含 nn 个整数 aia_{i}(1≤ai≤1091 \le a_{i} \le 10^{9})。

输入的额外约束:

  • 所有测试用例的 nn 值之和不超过 2⋅1052 \cdot 10^5。

输出格式

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

对于每个测试用例,输出一个整数——即该问题的答案。

输入输出样例

  • 输入#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

    输出#1

    3
    7
    10
    0

说明/提示

In the first example, there are 33 beautiful pairs: (1,21, 2), (1,31, 3), and (1,51, 5).

In the second example, there are 77 beautiful pairs: (1,31, 3), (1,51, 5), (2,42, 4), (2,62, 6), (3,43, 4), (3,53, 5), and (4,64, 6).

在第一个例子中,有 33 个优美对:(1,21, 2)、(1,31, 3) 和 (1,51, 5)。

在第二个例子中,有 77 个优美对:(1,31, 3)、(1,51, 5)、(2,42, 4)、(2,62, 6)、(3,43, 4)、(3,53, 5) 和 (4,64, 6)。

输入解题思路,AI测评打分。不知道怎么写?

首页