代码如下:
#include<cstdio>
#include<cstring>
int s[20];
long long int cal(int b, int e)
{
long long int sum = 1;
for(;b <= e; b++)
{
sum *= s[b];
}
return sum;
}
int main()
{
freopen("text.txt", "r", stdin);
int n;
while(scanf("%d", &n) != EOF)
{
long long int re = 1;
memset(s, 0, sizeof(s));
for(int i = 0; i < n; i++)
{
scanf("%d", s+i);
}
for(int be = 0; be < n; be++)
for(int ed = be; ed < n; ed++)
{
re = cal(be, ed)>re?cal(be,ed):re;
}
if(re < 0) puts("-1");
else
printf("%lld\n", re);
}
}

被折叠的 条评论
为什么被折叠?



