编程介的小学生 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 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建