题目地址
题意:定义F(x)为x的所有因子和,现在给你l,r,求 <mstyle displaystyle="true" scriptlevel="0"> <munderover> i = l r </munderover> </mstyle> \displaystyle\sum_{i=l}^{r} i=lrF(i)。
把问题转化为求 <mstyle displaystyle="true" scriptlevel="0"> <munderover> i = 1 r </munderover> </mstyle> \displaystyle\sum_{i=1}^{r} i=1rF(i)– <mstyle displaystyle="true" scriptlevel="0"> <munderover> i = 1 l 1 </munderover> </mstyle> \displaystyle\sum_{i=1}^{l-1} i=1l1F(i)。因为当我们列出一个数的所有前缀的因子:
eg:
F(1) = {1};
F(2) = {1, 2};
F(3) = {1, 3};
F(4) = {1, 2, 4};
F(5) = {1, 5};
F(6) = {1, 2, 3, 6};
所以就是在求
(n/1)* 1 + (n/2)*2+(n/3)*3+(n/4)*4+…+(n/n)*n
所以直接套一套数论分块的板子就好了。

/* * @Author: hannibal_lecter * @Date: 2018-10-30 16:53:01 * @Last Modified by: hannibal_lecter * @Last Modified time: 2018-10-30 17:00:16 */
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef unsigned long long ull;
const int maxn = 1e5+5;
const int mod = 1e9+9;
int Case = 1, n, m;
ull a, b;
ull cal(ull x) {
    if(x==1)return 1;
    ull ans=0,p=0;
    for(ull i = 1; i <= x;i = p+1){
        p = x/(x/i);
        ans += (x/i)*(i+p)*(p-i+1)/2;
    }
    return ans;
}
void solve(){
   	printf("%llu\n", cal(b)-cal(a-1));
    return;
}

int main() {
    //ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
    //freopen("/Users/hannibal_lecter/Desktop/code/in.txt", "r", stdin);
    //freopen("/Users/hannibal_lecter/Desktop/code/out.txt","w",stdout);
#endif
    while(scanf("%llu%llu", &a, &b) == 2) {
        solve();
    }
    return 0;
}