posted on 2023-05-07 20:53 read(671) comment(0) like(4) collect(3)
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.
The first line of input is N, L
The next N lines represent the N numbers in numbers, each line (10^-9 ≤ numbers[i] ≤ 10^9)
Output the position (counting from 0) and size of the subarray, separated by a space.
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
enter | 3 2 2 2 3 |
output | 1 2 |
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.
name:
Comment content: (supports up to 255 characters)
Copyright © 2018-2021 python black hole network All Rights Reserved All rights reserved, and all rights reserved.京ICP备18063182号-7
For complaints and reports, and advertising cooperation, please contact vgs_info@163.com or QQ3083709327
Disclaimer: All articles on the website are uploaded by users and are only for readers' learning and communication use, and commercial use is prohibited. If the article involves pornography, reactionary, infringement and other illegal information, please report it to us and we will delete it immediately after verification!