https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2000
困難度 ★ 注意輸出要多一行,還有必須使用long才會過
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int count=0;
while(scn.hasNext()){
int n=scn.nextInt(),arr[]=new int [n];
long max=0;
for(int i=0;i<n;i++)
arr[i]=scn.nextInt();
for(int i=0;i<n;i++){
long temp=1;
for(int j=i;j<n;j++){
temp*=arr[j];
if(temp>max)
max=temp;
}
}
System.out.printf("Case #%d: The maximum product is %d.\n\n",++count,max);
}
}
/*
題目:Q11059: Maximum Product
作者:1010
時間:西元 2016 年 7 月 */
}