CF2196B.Another Problem about Beautiful Pairs
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
In the array a, we call a pair of indices i, j beautiful if the following condition holds:
- ai⋅aj=j−i.
Count the number of beautiful pairs in the array a.
在数组 a 中,若下标对 i、j 满足以下条件,则称其为优美对:
- ai⋅aj=j−i。
请计算数组 a 中优美对的个数。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). The description of the test cases follows.
The first line of each test case contains a single integer n (2≤n≤2⋅105).
The second line of each test case contains n integers ai (1≤ai≤109).
Additional constraints on the input:
- The sum of n across all test cases does not exceed 2⋅105.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(2≤n≤2⋅105)。
每个测试用例的第二行包含 n 个整数 ai(1≤ai≤109)。
输入的额外约束:
- 所有测试用例的 n 值之和不超过 2⋅105。
输出格式
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 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).
在第一个例子中,有 3 个优美对:(1,2)、(1,3) 和 (1,5)。
在第二个例子中,有 7 个优美对:(1,3)、(1,5)、(2,4)、(2,6)、(3,4)、(3,5) 和 (4,6)。
输入解题思路,AI测评打分。不知道怎么写?