分析:水题,枚举起点和终点即可
1 #include "iostream" 2 #include "cstdio" 3 #include "cstring" 4 #include "string" 5 using namespace std; 6 const int maxn=25; 7 int a[maxn]; 8 int main() 9 { 10 int cas=0; 11 int n; 12 while(cin>>n) 13 { 14 for(int i=1;i<=n;i++) 15 cin>>a[i]; 16 long long ans=0; 17 for(int i=1;i<=n;i++){ 18 for(int j=1;j<=i;j++){ 19 long long cnt=1; 20 for(int k=j;k<=i;k++){ 21 cnt*=a[k]; 22 } 23 ans=max(cnt,ans); 24 } 25 } 26 printf("Case #%d: The maximum product is %lld. ",++cas,ans); 27 printf(" "); 28 } 29 return 0; 30 }