【题解】UVa P11059 【Maximum Product】

这题只需枚举起点和终点就好了。O(n^{3})

但是这个OJ特别二,输出有毛病,,,

#include<cstdio>
#include<vector>

namespace OI{
	using std::vector;
}
using namespace OI;

typedef long long int64;

inline int64 MAX(int64 a,int64 b){
	return a > b ? a : b;
}

int main(){
	//freopen("out1.txt","w",stdout);
	//freopen("in.txt","r",stdin);
	
	int n,T = 1;
	vector<int64> v;
	while(scanf("%d",&n) != EOF){	
		for(int i = 0;i < n;i++){
			int gg;scanf("%d",&gg);
			v.push_back(gg);
		}
		
		int64 ans = 1,max = -0x3f3f3f3f;
		for(int i = 0;i < n;i++){
			for(int j = i;j < n;j++){
				for(int k = i;k <= j;k++){
					ans *= v[k];
				}
				max = MAX(max,ans);
				ans = 1;
			}
		}
		
		printf("Case #%d: The maximum product is %lld.\n\n",T,max);
		
		max = -0x3f3f3f3f;
		T++;
		v.clear();
	}
	
	return 0;
}