# 魔法序列-upc

5
30 60 20 20 20


80

#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
///#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
///char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
const ll inf = 1e15;
const ll INF = 0x3f3f3f3f;
const int maxn = 2e6 + 7;
const int mod = 1e9 + 7;
ll gcd(ll a,ll b)
{
ll t;
while(b!=0)
{
t=a%b;
a=b;
b=t;
}
return a;
}
ll qPow(ll x, ll k)
{
ll res = 1;
while(k) {
if(k&1)
res=(res*x);
k>>=1;
x=(x*x);
}
return res;
}
ll maxx=-1;
ll minn=inf;
ll num2[maxn];
ll num[maxn];
ll res,ans;
int sum=0;
map<ll,ll> mp;
map<ll,ll> mpt;
vector<ll> vet;
priority_queue <int ,vector<int> ,greater<int> > xiaogen;
queue <ll> duilie;
priority_queue <int ,vector<int> ,less<int> > que;
///https://www.pasteme.cn/35934
int main()
{
ans=-1;
for(int i=1;i<=n;i++)///right
{
mp=mpt,mpt.clear();
ans=max(ans,num[i]);///本身的最大
if(mpt.count(num[i])==0)
mpt[num[i]]=i;
for(auto it=mp.begin();it!=mp.end();it++){
res=gcd(num[i],it->first);///it->first里面是存储的数，it->second里面是下标对于mpt来说
///对于前面区间的更新已经通过mp=mpt更新，所以对于mp亦是如此
ans=max(ans,res*(i-(it->second)+1));
///test:
///cout<<res<<endl;
///cout<<ans<<endl;
///更新端点
if(mpt.count(res)==0) mpt[res]=it->second;
else if(mpt.count(res)!=0) mpt[res]=min(mpt[res],it->second);
}
}
cout<<ans<<endl;
return 0;
}
/**
5
30 60 20 20 20
**/



05-05 84

05-06 147

09-30 7160

12-22 1004

09-23 698

04-27 495

07-26 1143

04-27 415

10-23 1438

#### 波斯公主选驸马： 关于算法和重大决策

©️2020 CSDN 皮肤主题: 深蓝海洋 设计师: CSDN官方博客

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