Reverse Game

TimeLimit:1000MS  MemoryLimit:32MB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

  Fat brother and Maze are playing a kind of special (hentai) game by N integers s1, s2… sn. Firstly Maze must arrange these n integers in a line, thus it makes an array S. Then Fat brother will randomly choose two indexes (l, r) with l < r and reverse interval S[l…r] (both inclusive). As Fat brother is such a boring guy, he will perform this action again and again for E times. After that, Fat brother and Maze will together randomly choose two indexes (l, r) with l < r and count the sum of interval S[l…r], let it be F. If F is large enough, Fat brother will be very happy and play a MORE special (hentai) game with Maze in the late night. (Maybe it’s the OOXX game which decrypted in the last problem, who knows.) As Maze loves Fat brother so much, she wants to make the expected value of F as large as possible so that she would have a greater chance to play this kind of MORE special (hentai) game with Fat brother.

  Now she turns for your help, how to arrange these n integers to make the expected value of F as large as possible? For convenience, you just need to output the expected value of F under this arrangement.

Input

  The first line of the date is an integer T, which is the number of the text cases.

  Then T cases follow, each case contains two integers N and E description above.

  Then a line with N integers s1, s2… sn.

1 <= T <=100, 2 <=N<= 100, 1 <= E <=1000000086, 1 <= si <= 10086

Output

  For each case, output the expected value of F under your arrangement. See the sample input and output for more details.

Your answer will be accepted if your absolute error for each number is no more than 10-4.

SampleInput
4
2 0
1 2
2 1
1 2
3 0
1 2 3
10 10
1 2 3 4 5 6 7 8 9 10
SampleOutput
3.000000
3.000000
5.000000
25.890449
Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数0
总提交量0
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: