思路:
AC代码
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;//必须是unsigned
ll f(ll n)//除法分块+等差数列求
{
ll left,right;
ll sum=0;
for(left=1; left<=n; left=right+1)//分块算因子和
{
right=n/(n/left);//这是一种规律
sum +=(n/left)*(left+right)*(right-left+1)/2;//等差数列公式
}
return sum;
}
int main()
{
ios::sync_with_stdio(0);
ll a,b;
cin>>a>>b;
cout<<f(b)-f(a-1)<<endl;
return 0;
}