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 39 40 41
| #include <bits/stdc++.h> #define ll long long #define int long long #define Orz ios::sync_with_stdio(0),cin.tie(0) #define N 20 #define FOR(i,n) for(int i=0;i<n;i++) #define pii pair<int,int> #define pid pair<int,double> #define pdi pair<double,int> using namespace std; int n,m;
void solve(){ int c = 0; while(cin>>n){ c++; int dp[N][N];memset(dp,0,sizeof(dp)); int ans = 0; FOR(i,n){ int temp;cin>>temp; dp[i][i] = temp; ans = max(ans,temp); } for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ dp[i][j] = dp[i][j-1]*dp[j][j]; ans = max(dp[i][j],ans); } } cout<<"Case #"<<c<<": The maximum product is "<<max(ans,(ll)0)<<"."<<endl; } }
signed main(){ Orz; int t = 1; while(t--){ solve(); } }
|