暴力,不过还是有坑。。。。发现了一个不常见的bug
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
long long a[110];
int main()
{
int n,cnt = 1;
while(~scanf("%d",&n)){
for(int i = 0 ; i < n ; i++)
scanf("%lld",&a[i]);
long long max_ = 0 , ans = 1;
for(int i = 0 ; i < n ; i++){
long long ans = a[i];
if(ans > max_) max_ = ans;//我一开始忽略了考虑只有一个就是max的情况,怒跪了
for(int j = i + 1 ; j < n ; j++){
ans *= a[j];
//printf("ans = %lld\n",ans);
if(ans > max_) max_ = ans;
}
}
//printf("Case #%d: The maximum product is %lld.\n\n",cnt++,max_);
printf("Case #%d: The maximum product is %lld.\n\n",cnt++,max_);
}
return 0;
}