1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
#include <iostream> #include <cstdio> #include <cstring> #define ll long long //-1000000000000000000 using namespace std; int main() { int n,kase=1; int a[20]; ll max_end_here,max_so_far; while(scanf("%d",&n)!=EOF) { for(int i=0;i<n;i++) { scanf("%d",&a[i]); } max_so_far=0; for(int i=0;i<n;i++) { for(int j=i;j<n;j++) { max_end_here=1; for(int k=i;k<=j;k++) { max_end_here*=a[k]; } if(max_so_far<max_end_here) max_so_far = max_end_here; } } printf("Case #%d: The maximum product is %lld.\n\n",kase++,max_so_far); } return 0; } |