2549. Funny Average

单点时限: 2.0 sec

内存限制: 256 MB

Take n integers.The average then needs to be computed. Call it Avg1.Forget all numbers that are lesser than Avg1.Compute the average of what is remaining. Call it Avg2.Forget all integers that have larger value than Avg2.Compute the average of what is remaining. Call it Avg3.

Continue this forever, throwing all the small ones, then the larger numbers, then the smaller numbers again, and so on. At one point, the average will cease to change. Your job is to figure out what that final “steady-state” average will be.

输入格式

The input should start with a line entering the number of cases or test cases, N. Each test case should consist of 2 lines, the first line giving n (1 <= n <= 30000), and the second line entering n integers (each one lies between -30000 and 30000).

输出格式

For all test cases, output should have one line containing “Case y:” followed by the final answer (average), rounded to three decimal places.

样例

Input
4
3
1 2 3
1
7
9
1 2 3 4 5 7 6 8 9
4
1 2 2 2
Output
Case #1: 2.000
Case #2: 7.000
Case #3: 6.000
Case #4: 2.000

18 人解决,71 人已尝试。

23 份提交通过,共有 199 份提交。

7.3 EMB 奖励。

创建: 15 年,3 月前.

修改: 6 年,11 月前.

最后提交: 4 年,1 月前.

来源: partychen

题目标签