链接:https://codeforces.com/group/nhsfFrN6WT/contest/266629/problem/D
You are given a positive integer nn greater or equal to 22. For every pair of integers aa and bb (2≤|a|,|b|≤n2≤|a|,|b|≤n), you can transform aa into bb if and only if there exists an integer xx such that 1<|x|1<|x| and (a⋅x=ba⋅x=b&nbs***bsp;b⋅x=ab⋅x=a), where |x||x| denotes the absolute value of xx.
After such a transformation, your score increases by |x||x| points and you are not allowed to transform aa into bb nor bb into aa anymore.
Initially, you have a score of 00. You can start at any integer and transform it as many times as you like. What is the maximum score you can achieve?
Input
A single line contains a single integer nn (2≤n≤1000002≤n≤100000) — the given integer described above.
Output
Print an only integer — the maximum score that can be achieved with the transformations. If it is not possible to perform even a single transformation for all possible starting integers, print 00.
Examples
input
Copy
4
output
Copy
8
input
Copy
6
output
Copy
28
input
Copy
2
output
Copy
0
Note
In the first example, the transformations are 2→4→(−2)→(−4)→22→4→(−2)→(−4)→2.
In the third example, it is impossible to perform even a single transformation.
代码:
#include<bits/stdc++.h>
using namespace std;
long long n,t,b,k,c,l,r,ans,vis=1,p,mx=0,kk=0,y=0;
long long a[1000001],x[1000001];
map<long long,long long>q[1000001];
long long s[1000001];
int main()
{
cin>>n;
ans=0;
for(int i=2;i<=n;i++)
{
k=sqrt(i);
l=0;
s[i]=0;
for(int j=2;j<=k;j++)
{
if(i%j==0)
{
if(q[i][j]==0)
{
l++;
s[i]+=(i/j)*4;
q[i][j]=1;
}
if(q[i][i/j]==0)
{
l++;
s[i]+=j*4;
q[i][i/j]=1;
}
}
}
ans+=s[i];
}
cout<<ans;
return 0;
}