Article From:https://www.cnblogs.com/mch5201314/p/9971092.html

Give you n, let you find any two numbers in the interval from 2 to n, so that one number is another factor and the absolute value is small and can become the absolute value is large.
Ask you the sum of absolute multiples multiplied by this process.

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[1000005];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    while(cin>>n){
        memset(a,0,sizeof(a));
        for(ll i=2;i*2<=n;i++)
        for(ll j=2;j*i<=n;j++)
        a[i*j]+=i+j;
        ll ans=0;
        for(ll i=4;i<=n;i++)
        ans+=2*a[i];
        cout<<ans<<endl;
    }
    return 0;
}
Link of this Article: D. Fun with Integers

Leave a Reply

Your email address will not be published. Required fields are marked *