#P9880. [EC Final 2021] Future Coder

[EC Final 2021] Future Coder

题目描述

Prof. Pang builds his famous coding team recently. To pursue a gold medal in ICPC, hundreds of pupils join his team. Unfortunately, one of Prof. Pang's students believes that for any integers aa and bb, a×ba+ba\times b\ge a+b. To disprove this proposition, Prof. Pang writes nn numbers a1,a2,,ana_1,a_2,\ldots, a_n on a paper and wants you to count how many pairs of numbers (ai,aj)(a_i, a_j) (1i<jn1\le i < j\le n) satisfies ai×aj<ai+aja_i\times a_j<a_i+a_j.

输入格式

The first line contains a single integer TT (1T1061\le T\le 10^6) denoting the number of test cases.

For each test case, the first line contains a single integer nn (1n1061\le n\le 10^6). The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (109ai109-10^9\le a_i\le 10^9).

It is guaranteed that the sum of nn over all test cases will not exceed 10610^6.

输出格式

For each test case, print one line containing the answer.

题目大意

题目描述

TT 组数据,每组给出一个数 nnnn 个数 a1,a2,...,ana_1,a_2,...,a_n,求有多少个二元组 (ai,aj)(a_i,a_j) 满足 aiaj<ai+aja_ia_j<a_i+a_j

输入格式

第一行为一个数 TT

接下来 TT 组数据,每组数据第一行为一个数 nn,第二行为 nn 个数 a1,a2,...,ana_1,a_2,...,a_n

输出格式

TT 行,为满足 aiaj<ai+aja_ia_j<a_i+a_j 的二元组 (ai,aj)(a_i,a_j) 的组数。

Translated from FurippuWRY

2
8
3 -1 4 1 -5 9 2 -6
1
0

19
0