News from this site

 Rental advertising space, please contact the webmaster if you need cooperation


+focus
focused

classification  

no classification

tag  

no tag

date  

no datas

华为OD机试 - 几何平均值最大子数组(Java & JS & Python)

posted on 2023-05-07 20:53     read(614)     comment(0)     like(4)     collect(3)


topic description

Find the subarray with length at least L and the largest geometric mean from a positive array numbers of length N, and output its position and size. (The geometric mean of K numbers is the Kth root of the product of K numbers)

If the geometric mean of multiple subarrays is the maximum value, then output the subarray with the smallest length.

If there are multiple subarrays with the same length whose geometric mean is the maximum value, then output the first subarray.

enter description

The first line of input is N, L

  • N represents the size of numbers (1 ≤ N ≤ 100000)
  • L represents the minimum length of the subarray (1 ≤ L ≤ N)

The next N lines represent the N numbers in numbers, each line (10^-9 ≤ numbers[i] ≤ 10^9)

output description

Output the position (counting from 0) and size of the subarray, separated by a space.

Remark

The use case guarantees that, except for the subarray whose geometric mean is the maximum value, the geometric mean of the other subarrays is at least 10^-10 times smaller than the maximum value

Example

enter 3 2
2
2
3
output 1 2


Category of website: technical article > Blog

Author:cindy

link:http://www.pythonblackhole.com/blog/article/383/bd87109c3ddb141bfc5d/

source:python black hole net

Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.

4 0
collect article
collected

Comment content: (supports up to 255 characters)