问题类型:暴力枚举
问题链接
03pie’s solution for [UVA-11059]:
#include<bits/stdc++.h>//包含所有头文件
using namespace std;typedef long long LL;
const double PI=acos(-1.0);const int maxn=18+2;
int a[maxn];
int main(){// freopen("F://inp.txt","r",stdin);int n,kase=0;while(~scanf("%d",&n)){LL max=0;for(int i=0;i<n;i++) scanf("%d",&a[i]);for(int i=0;i<n;i++){LL tmp=a[i];for(int j=i+1;j<n;j++){if(tmp>max) max=tmp;tmp=tmp*a[j];
// if(tmp>max) max=tmp;}if(tmp>max) max=tmp;}printf("Case #%d: The maximum product is %lld.\n\n",++kase,max);} return 0;
}