题目
思路
见大佬博客->添加链接描述
代码
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
int main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll n,k;
cin>>n>>k;
ll l=2,res=0,r;
for(l=2;l<=n&&l<=k;l=r+1){
r=min((n/(n/l)),k);
res=(res+((r-l+1)%mod*(n/l)%mod)%mod)%mod;
}
r=l=2;
for(l=2;l<=n-1&&l<=k;l=r+1){
r=min(((n-1)/((n-1)/l)),k);
res=(res+((r-l+1)%mod*((n-1)/l)%mod)%mod)%mod;
l=r+1;
}
cout<<(n+res+k-1)%mod<<endl;
return 0;
}