五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
文山县| 桐城市| 宜城市| 平定县| 潼南县| 义乌市| 雷山县| 临高县| 屯昌县| 澄迈县| 阜阳市| 澎湖县| 康乐县| 秦皇岛市| 临城县| 大竹县| 郑州市| 藁城市| 佛山市| 安丘市| 金乡县| 彩票| 平顶山市| 张家港市| 宁明县| 崇明县| 交城县| 中江县| 区。| 栾川县| 姚安县| 墨玉县| 泽普县| 饶河县| 黄平县| 兴文县| 离岛区| 深圳市| 休宁县| 同心县| 台州市|