当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5805:NanoApe Loves Sequence

题目描述
NanoApe, the Retired Dog, has returned back to prepare for the National Higher Education Entrance Examination!

In math class, NanoApe picked up sequences once again. He wrote down a sequence with $n$ numbers on the paper and then randomly deleted a number in the sequence. After that, he calculated the maximum absolute value of the difference of each two adjacent remained numbers, denoted as $F$.

Now he wants to know the expected value of $F$, if he deleted each number with equal probability.
输入解释
The first line of the input contains an integer $T$, denoting the number of test cases.

In each test case, the first line of the input contains an integer $n$, denoting the length of the original sequence.

The second line of the input contains $n$ integers $A_1, A_2, ..., A_n$, denoting the elements of the sequence.

$1 \le T \le 10,~3 \le n \le 100000,~1 \le A_i \le 10^9$
输出解释
For each test case, print a line with one integer, denoting the answer.

In order to prevent using float number, you should print the answer multiplied by $n$.
输入样例
1
4
1 2 3 4
输出样例
6
来自杭电HDUOJ的附加信息
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 BestCoder Round #86

源链接: HDU-5805

最后修改于 2020-10-25T23:25:47+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 262144/131072K(Java/Others)