个人网站建设方案,我要注册电子邮箱,软件源地址大全,有网站用nodejs做后台题意#xff1a;给出n个数组成的序列#xff0c;求乘积最大的连续子序列 看的紫书#xff0c;因为n最大为18#xff0c;每个数最大为10,所以10^18用long long 能够存下#xff0c; 直接枚举起点和终点找最大值就可以了 1 #includeiostream 2 #includecstdio给出n个数组成的序列求乘积最大的连续子序列 看的紫书因为n最大为18每个数最大为10,所以10^18用long long 能够存下 直接枚举起点和终点找最大值就可以了 1 #includeiostream 2 #includecstdio 3 #includecstring 4 #include cmath 5 #includestack6 #includevector7 #includemap 8 #includequeue 9 #includealgorithm
10 #define mod1e97;
11 using namespace std;
12
13 typedef long long LL;
14 int a[105];
15
16 int main(){
17 LL ans,maxn;
18 int i,j,n,cas1;
19 while(scanf(%d,n)!EOF){
20 for(i1;in;i) scanf(%d,a[i]);
21 maxn-1000;
22
23 for(i1;in;i){
24 ansa[i];
25 maxnmax(ans,maxn);
26 for(ji1;jn;j){
27 ans*a[j];
28 maxnmax(ans,maxn);
29 // printf(ans%d\n,ans);
30
31 }
32 }
33 if(maxn0) maxn0;
34 printf(Case #%d: The maximum product is %lld.\n\n,cas,maxn);
35 }
36 return 0;
37 } View Code 转载于:https://www.cnblogs.com/wuyuewoniu/p/4346025.html