#include<bits/stdc++.h>
#define LL long long int
#define ll long long int
using namespace std;
LL product(vector<int>v)
{
LL finals = 0;
ll total = 1;
int i;
for(i=0;i<v.size();i++)
{
total = 1LL * total * v[i];
if(finals < total && (total > 1 || v[i] == 1))
{
finals = total;
}
if(total == 0)
total = 1;
}
return finals;
}
int main()
{
int n, i, m, j = 1;
while(cin >> n)
{
vector<int>v;
for(i=1;i<=n;i++)
{
cin >> m;
v.push_back(m);
}
LL r1 = product(v);
reverse(v.begin(), v.end());
LL r2 = product(v);
LL r = max(r1, r2);
cout << "Case #" << j++ << ": The maximum product is " << r << "." << endl << endl;
}
return 0;
}
#define LL long long int
#define ll long long int
using namespace std;
LL product(vector<int>v)
{
LL finals = 0;
ll total = 1;
int i;
for(i=0;i<v.size();i++)
{
total = 1LL * total * v[i];
if(finals < total && (total > 1 || v[i] == 1))
{
finals = total;
}
if(total == 0)
total = 1;
}
return finals;
}
int main()
{
int n, i, m, j = 1;
while(cin >> n)
{
vector<int>v;
for(i=1;i<=n;i++)
{
cin >> m;
v.push_back(m);
}
LL r1 = product(v);
reverse(v.begin(), v.end());
LL r2 = product(v);
LL r = max(r1, r2);
cout << "Case #" << j++ << ": The maximum product is " << r << "." << endl << endl;
}
return 0;
}
Comments
Post a Comment