编程介的小学生 2017-09-12 17:07 采纳率: 20.5%
浏览 702
已采纳

Mean of Means

Given N numbers in a circle, we can determine a continuous subsequence by giving its start position and its length. PMH and Roy played a game the other day. Roy gives the start position first, then PMH gives the length. Roy wants the mean of the subsequece as large as possible, but he doesn't know the length that PMH will choose. Assume that the length L(0 < L <= N) PMH will choose is random, so there are N possible means that Roy may get. For each start position, there is a mean of all the N means described above, and Roy will choose the start position with the maximal mean.

Input

There are multiple test cases.
Each test case begins with a line containing N only (N < 20000 and N is power of 2).
The following line contains N numbers, separated by spaces.

Output

For each test case, you are to print the maximal mean Roy can get, accurate up to 2 decimal places.

Sample Input

4
1 2 3 4

Sample Output

2.92

Note

Assume the start position is 1.
If PMH chooses the length 1, the mean of the subsequece is 1 / 1 = 1.
If PMH chooses the length 2, the mean of the subsequece is (1 + 2) / 2 = 1.5.
If PMH chooses the length 3, the mean of the subsequece is (1 + 2 + 3) / 3 = 2.
If PMH chooses the length 4, the mean of the subsequece is (1 + 2 + 3 + 4) / 4 = 2.5.
So we get the mean of 1, 1.5, 2 and 2.5 as 1.75.

If Roy let the start position be 3, he can get the maximal mean 2.92.

  • 写回答

1条回答 默认 最新

  • devmiao 2017-09-13 00:45
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办