P15706 [CodeChef] PAIRPAIN
普及-
题目描述

You are given an array A containing N positive integers. Find the number of pairs (i,j) such that 1 ≤ i < j ≤ N and:
A_{i} + A_{j} ≥ $A_{i} \cdot A_{j}$

------ Input Format ------

  • The first line contains an integer T denoting the number of test cases. The T test cases then follow.
  • The first line of each test case contains an integer N.
  • The second line of each test case contains $N space-separated integers A_{1}, A_{2}, \ldots, A_{N}$.

------ Output Format ------

For each test case, output on a new line the required answer.

------ Constraints ------

$1 ≤T ≤1000$
$2 ≤N ≤2 \cdot 10^{5}$
$1 ≤A_{i} ≤10^{6}$
- Sum of $N$ over all cases won't exceed $2 \cdot 10^{5}$

----- Sample Input 1 ------
2
3
1 3 4
5
2 3 4 5 6
----- Sample Output 1 ------
2
0
----- explanation 1 ------
Test case $1$: The two pairs are $(1, 2)$ and $(1, 3)$, because:
- $A_{1} + A_{2} = 4 > 3 = A_{1} \cdot A_{2}$
- $A_{1} + A_{3} = 5 > 4 = A_{1} \cdot A_{3}$

Test case $2$: No pairs satisfy the condition.

输入格式

见题面

输出格式

见题面

样例输入
2 3 1 3 4 5 2 3 4 5 6
样例输出
2 0