This commit is contained in:
Zengtudor 2024-08-16 10:53:13 +08:00
parent b130e643b8
commit 012325cdda
1 changed files with 40 additions and 40 deletions

View File

@ -1,40 +1,40 @@
#include<bits/stdc++.h> // #include<bits/stdc++.h>
#define int long long // #define int long long
using namespace std; // using namespace std;
int n; // int n;
int a[1005]; // int a[1005];
int zs[50005]; // int zs[50005];
int tot; // int tot;
signed main(){ // signed main(){
ios::sync_with_stdio(0); // ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0); // cin.tie(0);cout.tie(0);
cin>>n; // cin>>n;
for(int i=1;i<=n;i++)cin>>a[i]; // for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++){ // for(int i=1;i<=n;i++){
int t=a[i]; // int t=a[i];
for(int j=2;j*j<=t;j++){ // for(int j=2;j*j<=t;j++){
if(t%j==0){ // if(t%j==0){
zs[++tot]=j; // zs[++tot]=j;
// cout<<j<<" "; // // cout<<j<<" ";
while(t%j==0)t/=j; // while(t%j==0)t/=j;
} // }
} // }
if(t>1){ // if(t>1){
//cout<<t<<" "; // //cout<<t<<" ";
zs[++tot]=t; // zs[++tot]=t;
} // }
//cout<<endl; // //cout<<endl;
} // }
sort(zs+1,zs+tot+1); // sort(zs+1,zs+tot+1);
tot=unique(zs+1,zs+tot+1)-zs-1; // tot=unique(zs+1,zs+tot+1)-zs-1;
int ans=0; // int ans=0;
for(int i=1;i<=tot;i++){ // for(int i=1;i<=tot;i++){
int now=0; // int now=0;
int tt=zs[i]; // int tt=zs[i];
for(int j=1;j<=n;j++){ // for(int j=1;j<=n;j++){
if(a[j]%tt==0)now+=a[j]; // if(a[j]%tt==0)now+=a[j];
} // }
ans=max(ans,now); // ans=max(ans,now);
} // }
cout<<ans; // cout<<ans;
} // }