308574: CF1541B. Pleasant Pairs
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Pleasant Pairs
题意翻译
给你一个长度为 $n$ 的序列,且元素两两不同,你需要求出满足 $i<j$ 且 $i+j=a_i\cdot a_j$ 的数对个数。 $n\le 10^5 , 1\le a_i \le 2n $ 多组数据,$\sum n \le 2\times 10^5$题目描述
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 < j $ and $ a_i \cdot a_j = i + j $ .输入输出格式
输入格式
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 $ .
输出格式
For each test case, output the number of pairs of indices $ (i, j) $ such that $ i < j $ and $ a_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