Maximum continuous product | ||||||
| ||||||
Description | ||||||
Wind and his GF(game friend) are playing a small game. They use the computer to randomly generated a number sequence which only include number 2,0 and -2. To be the winner,wind must have to find a continuous subsequence whose continuous product is maximum. For example, we have a sequence blow: 2 2 0 -2 0 2 2 -2 -2 0 Among all of it's continuous subsequences, 2 2 -2 -2 own the maximum continuous product. (2*2*(-2)*(-2) = 16 ,and 16 is the maximum continuous product) You,wind's friend,can give him a hand.
| ||||||
Input | ||||||
The first line is an integer T which is the Case number(T <= 200). For each test case, there is an integer N indicating the length of the number sequence.(1<= N <= 10000) The next line,there are N integers which only include 2,0 and -2.
| ||||||
Output | ||||||
For each case,you have to output the case number first(Reference the sample). If the answer is smaller than 0, you just need to output 0 as the answer. If the answer's format is 2^x,you need to output the x as the answer. Output the answer in one line.
| ||||||
Sample Input | ||||||
2 2 -2 0 10 2 2 0 -2 0 2 2 -2 -2 0 | ||||||
Sample Output | ||||||
Case #1: 0 Case #2: 4 题意有点坑,没明说可以在一段中截取一段计算乘积
|
Hust oj 2116 Maximum continuous product(水题)
最新推荐文章于 2023-11-01 17:36:47 发布