国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

CF 1771A - Hossam and Combinatorics

2023-07-05 08:15 作者:您是打尖兒還是住店呢  | 我要投稿

Hossam woke up bored, so he decided to create an interesting array with his friend Hazem.

Now, they have an array a of n positive integers, Hossam will choose a number ai and Hazem will choose a number aj.

Count the number of interesting pairs (ai,aj) that meet all the following conditions:1≤i,j≤n;i≠j;

The absolute difference |ai?aj| must be equal to the maximum absolute difference over all the pairs in the array. More formally, |ai?aj|=max1≤p,q≤n|ap?aq|.

Input

The input consists of multiple test cases. The first line contains a single integer t (1≤t≤100), which denotes the number of test cases. Description of the test cases follows.

The first line of each test case contains an integer n (2≤n≤105).


The second line of each test case contains n integers a1,a2,…,an (1≤ai≤105).

It is guaranteed that the sum of n over all test cases does not exceed 105.

Output

For each test case print an integer — the number of interesting pairs (ai,aj).

---------------------------------------------------------------

Hossam 醒來感到很無聊,所以他決定和他的朋友 Hazem 一起創(chuàng)建一個有趣的數(shù)組。

現(xiàn)在,他們有一個由 n 個正整數(shù)組成的數(shù)組 a,Hossam 將選擇一個數(shù)字 ai,Hazem 將選擇一個數(shù)字 aj。

計算滿足以下所有條件的有趣對 (ai,aj) 的數(shù)量:1≤i,j≤n;i≠j;

絕對差|ai?aj| 必須等于數(shù)組中所有對的最大絕對差。 更正式地說,|ai?aj|=max1≤p,q≤n|ap?aq|。

輸入

輸入由多個測試用例組成。 第一行包含一個整數(shù)t(1≤t≤100),表示測試用例的數(shù)量。 測試用例的描述如下。

每個測試用例的第一行包含一個整數(shù)n(2≤n≤105)。


每個測試用例的第二行包含n個整數(shù)a1,a2,…,an

? (1≤ai≤105)。

保證所有測試用例的n之和不超過105。

輸出

對于每個測試用例,打印一個整數(shù) - 有趣的對 (ai,aj) 的數(shù)量。

----------------------------

踩了2個坑,一個是乘積會溢出的情況,沒有看示例的數(shù)據(jù)范圍,一個是沒有考慮極端情況,也就是所有的值全部相當?shù)臅r候。

其他沒什么問題的,下面是代碼:


CF 1771A - Hossam and Combinatorics的評論 (共 條)

分享到微博請遵守國家法律
当阳市| 灌云县| 新巴尔虎右旗| 手机| 五莲县| 亚东县| 漳州市| 肇州县| 奈曼旗| 惠安县| 民勤县| 成武县| 铁力市| 河间市| 定日县| 松原市| 南郑县| 桑植县| 嘉禾县| 通城县| 永仁县| 邢台县| 辰溪县| 闵行区| 莱西市| 鄂州市| 崇礼县| 阿拉尔市| 雷山县| SHOW| 栾川县| 正镶白旗| 息烽县| 陕西省| 惠来县| 武山县| 吴川市| 稷山县| 波密县| 玉溪市| 清远市|