UVa11059

对于连续子序列问题,如果数据范围小的话,可以枚举起点和终点。

 1 #include <iostream>
 2 #include <cstring>
 3 #include <string>
 4 #include <map>
 5 #include <set>
 6 #include <algorithm>
 7 #include <fstream>
 8 #include <cstdio>
 9 #include <cmath>
10 #include <stack>
11 #include <queue>
12 using namespace std;
13 const double Pi=3.14159265358979323846;
14 typedef long long ll;
15 const int MAXN=5000+5;
16 const int dx[5]={0,0,0,1,-1};
17 const int dy[5]={1,-1,0,0,0};
18 const int INF = 0x3f3f3f3f;
19 const int NINF = 0xc0c0c0c0;
20 const ll mod=1e9+7;
21 int a[100];
22 int main()
23 {
24     int n;int cnt=0;
25     while(cin>>n)
26     {    cnt++;
27         for(int i=1;i<=n;i++)
28             scanf("%d",&a[i]);
29         ll maxn=0;
30         for(int i=1;i<=n;i++)
31         {
32             for(int j=i;j<=n;j++)
33             {
34                 ll sum=1;
35                 for(int k=i;k<=j;k++)
36                 {
37                     sum*=a[k];
38                 }
39                 if(sum>maxn) maxn=sum;
40             }
41         }
42         printf("Case #%d: The maximum product is %lld.\n\n",cnt,maxn);
43     }
44     return 0;
45  } 

 

转载于:https://www.cnblogs.com/Msmw/p/10637289.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值