update pdf

This commit is contained in:
Zengtudor 2024-08-14 15:13:04 +08:00
parent 4d8d6bda29
commit fc5fc3cbd5
2 changed files with 16 additions and 9 deletions

BIN
day12/20240814sol.pdf Normal file

Binary file not shown.

View File

@ -4,9 +4,10 @@
using namespace std;
#define int long long
const int MAX_N = 2e8+5;
const int MAX_N = 1000+5;
int a[MAX_N];
int n,amax=INT_MIN,ans=0;
unordered_map<int,long long> um;
int readint();
signed main(signed argc,char *argv[]){
@ -22,16 +23,22 @@ signed main(signed argc,char *argv[]){
#endif
n=readint();
for(int i=1;i<=n;i++){
int input=readint();
a[input]++;
amax=max(amax,input);
a[i]=readint();
}
for(int i=2;i<=amax;i++){
int nans = 0;
for(int j=1;(i*j)<=amax;j++){
nans+=a[i*j]*i*j;
for(int i=1;i<=n;i++){
int num=a[i];
for(int j=2;j<=sqrt(a[i]);j++){
if(num%j==0){
um[j]+=a[i];
while(num%j==0)num/=j;
}
}
ans=max(ans,nans);
if(num>1){
um[num]+=a[i];
}
}
for(auto i : um){
ans+=i.second;
}
cout<<ans<<endl;
#ifdef OITEST