[http://codeforces.com/contest/1062/problem/D]
给你n,让你从2到n这个区间找任意两个数,使得一个数是另一个的因子,绝对值小的可以变为绝对值大的
问你这变化过程所乘的倍数绝对值之和
见过最简单的D题,直接在范围内找出倍数并保存倍数
自己看样例也就知道只是正负换了
因为会重复所不乘以4而是乘以2,看代码就知道了
#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;
}原文:https://www.cnblogs.com/mch5201314/p/9971092.html