1 #include <bits/stdc++.h> 2 #define _for(i,a,b) for(int i = (a);i < (b);i ++) 3 using namespace std; 4 5 int readint() 6 {int tmp;scanf("%d",&tmp);return tmp;} 7 8 int main() 9 { 10 int n,kase = 1; 11 while(~scanf("%d",&n)) 12 { 13 vector<int> v; 14 while(n --) 15 v.push_back(readint()); 16 17 long long rnt = -393939; 18 _for(i,0,v.size()) 19 _for(j,i,v.size()) 20 { 21 long long int trnt = 1; 22 _for(k,i,j+1) 23 { 24 trnt *= v[k]; 25 if(trnt>rnt) 26 rnt = trnt; 27 } 28 } 29 if(rnt<0) 30 rnt = 0; 31 printf("Case #%d: The maximum product is %lld. ",kase ++,rnt); 32 } 33 return 0; 34 }
又是一道PE题,佛了